Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -r9908e067a5350bea350dea231dbe734558e67be8 -r5a56024b9d5241a08dd08252c5be795a3a024912 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 9908e067a5350bea350dea231dbe734558e67be8) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 5a56024b9d5241a08dd08252c5be795a3a024912) @@ -194,14 +194,18 @@ @Override public Scratchie getScratchieByContentId(Long contentId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getScratchieByContentId(), getting Scratchie by content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getScratchieByContentId(), getting Scratchie by content ID: " + contentId); + } Scratchie rs = scratchieDao.getByContentId(contentId); if (rs == null) { ScratchieServiceImpl.log.debug("Could not find the content by given ID:" + contentId); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leafing getScratchieByContentId(), retrieved Scratchie by content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leafing getScratchieByContentId(), retrieved Scratchie by content ID: " + contentId); + } return rs; } @@ -222,11 +226,15 @@ @Override public List getAuthoredItems(Long scratchieUid) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getAuthoredItems(), getting ScratchieItems by Scratchie UID: " + scratchieUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getAuthoredItems(), getting ScratchieItems by Scratchie UID: " + scratchieUid); + } List res = scratchieItemDao.getAuthoringItems(scratchieUid); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getAuthoredItems(), retrieved ScratchieItems by Scratchie UID: " + scratchieUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getAuthoredItems(), retrieved ScratchieItems by Scratchie UID: " + scratchieUid); + } return res; } @@ -254,32 +262,42 @@ @Override public void createUser(ScratchieUser scratchieUser) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered createUser(), saving ScratchieUser login: " + scratchieUser.getLoginName()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered createUser(), saving ScratchieUser login: " + scratchieUser.getLoginName()); + } scratchieUserDao.saveObject(scratchieUser); } @Override public ScratchieUser getUserByIDAndContent(Long userId, Long contentId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getUserByIDAndContent(), getting ScratchieUser by ID: " + userId + " and content ID: " - + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getUserByIDAndContent(), getting ScratchieUser by ID: " + userId + + " and content ID: " + contentId); + } ScratchieUser res = scratchieUserDao.getUserByUserIDAndContentID(userId, contentId); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getUserByIDAndContent(), retrieved ScratchieUser by ID: " + userId + " and content ID: " - + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getUserByIDAndContent(), retrieved ScratchieUser by ID: " + userId + + " and content ID: " + contentId); + } return res; } @Override public ScratchieUser getUserByIDAndSession(Long userId, Long sessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getUserByIDAndSession(), getting ScratchieUser by ID: " + userId + " and session ID: " - + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getUserByIDAndSession(), getting ScratchieUser by ID: " + userId + + " and session ID: " + sessionId); + } ScratchieUser res = scratchieUserDao.getUserByUserIDAndSessionID(userId, sessionId); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getUserByIDAndSession(), retrieved ScratchieUser by ID: " + userId + " and session ID: " - + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getUserByIDAndSession(), retrieved ScratchieUser by ID: " + userId + + " and session ID: " + sessionId); + } return res; } @@ -296,8 +314,10 @@ @Override public void saveOrUpdateScratchie(Scratchie scratchie) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered saveOrUpdateScratchie(), saving Scratchie UID: " + scratchie.getUid()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered saveOrUpdateScratchie(), saving Scratchie UID: " + scratchie.getUid()); + } scratchieDao.saveObject(scratchie); } @@ -308,45 +328,60 @@ @Override public void deleteScratchieItem(Long uid) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered deleteScratchieItem(), deleting ScratchieItem UID: " + uid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered deleteScratchieItem(), deleting ScratchieItem UID: " + uid); + } scratchieItemDao.removeObject(ScratchieItem.class, uid); } @Override public ScratchieUser checkLeaderSelectToolForSessionLeader(ScratchieUser user, Long toolSessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: checkLeaderSelectToolForSessionLeader(), for ScratchieUser ID: " + user.getUserId() - + " and ScratchieSession ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: checkLeaderSelectToolForSessionLeader(), for ScratchieUser ID: " + user.getUserId() + + " and ScratchieSession ID: " + toolSessionId); + } if ((user == null) || (toolSessionId == null)) { return null; } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSession by ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSession by ID: " + toolSessionId); + } ScratchieSession scratchieSession = getScratchieSessionBySessionId(toolSessionId); ScratchieUser leader = scratchieSession.getGroupLeader(); // check leader select tool for a leader only in case scratchie tool doesn't know it. As otherwise it will screw // up previous scratches done if (leader == null) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ToolSession by ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ToolSession by ID: " + toolSessionId); + } ToolSession toolSession = toolService.getToolSession(toolSessionId); ToolActivity qaActivity = toolSession.getToolActivity(); Activity leaderSelectionActivity = ScratchieServiceImpl.getNearestLeaderSelectionActivity(qaActivity); // check if there is leaderSelectionTool available if (leaderSelectionActivity != null) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting User by ID: " + user.getUserId()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + + Thread.activeCount() + "]: getting User by ID: " + user.getUserId()); + } User learner = (User) getUserManagementService().findById(User.class, user.getUserId().intValue()); String outputName = ScratchieConstants.LEADER_SELECTION_TOOL_OUTPUT_NAME_LEADER_USERID; - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ToolSession by User: " + learner.getUserId() + " and activity ID: " - + leaderSelectionActivity.getActivityId()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + + Thread.activeCount() + "]: getting ToolSession by User: " + learner.getUserId() + + " and activity ID: " + leaderSelectionActivity.getActivityId()); + } ToolSession leaderSelectionSession = lamsCoreToolService.getToolSessionByLearner(learner, leaderSelectionActivity); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ToolOutput by session ID: " + leaderSelectionSession.getToolSessionId()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + + Thread.activeCount() + "]: getting ToolOutput by session ID: " + + leaderSelectionSession.getToolSessionId()); + } ToolOutput output = lamsCoreToolService.getOutputFromTool(outputName, leaderSelectionSession, null); // check if tool produced output @@ -357,8 +392,10 @@ // create new user in a DB if (leader == null) { ScratchieServiceImpl.log.debug("creating new user with userId: " + userId); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" - + Thread.activeCount() + "]: getting User by ID: " + userId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + + Thread.activeCount() + "]: getting User by ID: " + userId); + } User leaderDto = (User) getUserManagementService().findById(User.class, userId.intValue()); leader = new ScratchieUser(leaderDto.getUserDTO(), scratchieSession); this.createUser(leader); @@ -371,8 +408,10 @@ } } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving checkLeaderSelectToolForSessionLeader()"); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving checkLeaderSelectToolForSessionLeader()"); + } return leader; } @@ -381,15 +420,19 @@ * activities set first, and then inside the parent set. */ private static Activity getNearestLeaderSelectionActivity(Activity activity) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getNearestLeaderSelectionActivity() for activity ID: " + activity.getActivityId()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getNearestLeaderSelectionActivity() for activity ID: " + activity.getActivityId()); + } // check if current activity is Leader Select one. if so - stop searching and return it. Class activityClass = Hibernate.getClass(activity); if (activityClass.equals(ToolActivity.class)) { ToolActivity toolActivity; - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: doing strange stuff with Hibernate in getNearestLeaderSelectionActivity()"); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: doing strange stuff with Hibernate in getNearestLeaderSelectionActivity()"); + } // activity is loaded as proxy due to lazy loading and in order to prevent quering DB we just re-initialize // it here again Hibernate.initialize(activity); @@ -401,9 +444,12 @@ } if (ScratchieConstants.LEADER_SELECTION_TOOL_SIGNATURE.equals(toolActivity.getTool().getToolSignature())) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getNearestLeaderSelectionActivity() with activity found ID: " - + activity.getActivityId()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + + Thread.activeCount() + + "]: leaving getNearestLeaderSelectionActivity() with activity found ID: " + + activity.getActivityId()); + } return activity; } } @@ -421,8 +467,10 @@ return ScratchieServiceImpl.getNearestLeaderSelectionActivity(parent); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getNearestLeaderSelectionActivity() with no result"); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getNearestLeaderSelectionActivity() with no result"); + } return null; } @@ -434,14 +482,14 @@ ScratchieSession session = this.getScratchieSessionBySessionId(sessionId); int oldMark = session.getMark(); - + session.setMark(newMark); scratchieSessionDao.saveObject(session); // propagade new mark to Gradebook for all students in a group List users = this.getUsersBySession(sessionId); for (ScratchieUser user : users) { - + gradebookService.updateActivityMark(new Double(newMark), null, user.getUserId().intValue(), user .getSession().getSessionId(), true); @@ -454,65 +502,85 @@ @Override public Scratchie getScratchieBySessionId(Long sessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getScratchieBySessionId(), getting ScratchieSession by ID: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getScratchieBySessionId(), getting ScratchieSession by ID: " + sessionId); + } ScratchieSession session = scratchieSessionDao.getSessionBySessionId(sessionId); // to skip CGLib problem Long contentId = session.getScratchie().getContentId(); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting Scratchie by content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting Scratchie by content ID: " + contentId); + } Scratchie res = scratchieDao.getByContentId(contentId); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getScratchieBySessionId(), retrieved Scratchie by ScratchieSession ID: " + sessionId - + " and content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getScratchieBySessionId(), retrieved Scratchie by ScratchieSession ID: " + sessionId + + " and content ID: " + contentId); + } return res; } @Override public ScratchieSession getScratchieSessionBySessionId(Long sessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getScratchieSessionBySessionId(), getting ScratchieSession by ID: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getScratchieSessionBySessionId(), getting ScratchieSession by ID: " + sessionId); + } ScratchieSession res = scratchieSessionDao.getSessionBySessionId(sessionId); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getScratchieSessionBySessionId(), session retrieved by ID: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getScratchieSessionBySessionId(), session retrieved by ID: " + sessionId); + } return res; } @Override public void saveOrUpdateScratchieSession(ScratchieSession resSession) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered saveOrUpdateScratchieSession(), saving ScratchieSession with ID: " - + resSession.getSessionId()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered saveOrUpdateScratchieSession(), saving ScratchieSession with ID: " + + resSession.getSessionId()); + } scratchieSessionDao.saveObject(resSession); } @Override public void recordItemScratched(Long sessionId, Long answerUid) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered recordItemScratched(), getting ScratchieAnswer by UID: " + answerUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered recordItemScratched(), getting ScratchieAnswer by UID: " + answerUid); + } ScratchieAnswer answer = this.getScratchieAnswerByUid(answerUid); if (answer == null) { return; } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieAnswerVisitLog by ScratchieAnswer UID : " + answerUid - + " and sessionId: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieAnswerVisitLog by ScratchieAnswer UID : " + answerUid + " and sessionId: " + + sessionId); + } ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getLog(answerUid, sessionId); if (log == null) { log = new ScratchieAnswerVisitLog(); log.setScratchieAnswer(answer); log.setSessionId(sessionId); log.setAccessDate(new Timestamp(new Date().getTime())); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: saving ScratchieAnswerVisitLog for ScratchieAnswer UID : " + answerUid - + " and ScratchieSession ID: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: saving ScratchieAnswerVisitLog for ScratchieAnswer UID : " + answerUid + + " and ScratchieSession ID: " + sessionId); + } scratchieAnswerVisitDao.saveObject(log); } this.recalculateMarkForSession(sessionId, false); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving recordItemScratched() for ScratchieAnswer UID: " + answerUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving recordItemScratched() for ScratchieAnswer UID: " + answerUid); + } } /** @@ -523,9 +591,11 @@ */ @Override public void recalculateMarkForSession(Long sessionId, boolean isPropagateToGradebook) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered recalculateMarkForSession(), getting ScratchieAnswerVisitLog by sessionId : " - + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered recalculateMarkForSession(), getting ScratchieAnswerVisitLog by sessionId : " + + sessionId); + } List userLogs = scratchieAnswerVisitDao.getLogsBySession(sessionId); ScratchieSession session = this.getScratchieSessionBySessionId(sessionId); Scratchie scratchie = session.getScratchie(); @@ -542,60 +612,81 @@ // change mark for all learners in a group session.setMark(mark); scratchieSessionDao.saveObject(session); - + // propagade changes to Gradebook if (isPropagateToGradebook) { List users = this.getUsersBySession(sessionId); for (ScratchieUser user : users) { - - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: using GradebookService to update ActivityMark for ScratchieUser ID: " + user.getUserId() - + " and ScratchieSession ID: " + user.getSession().getSessionId()); + + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + + Thread.activeCount() + + "]: using GradebookService to update ActivityMark for ScratchieUser ID: " + + user.getUserId() + " and ScratchieSession ID: " + user.getSession().getSessionId()); + } gradebookService.updateActivityMark(new Double(mark), null, user.getUserId().intValue(), user .getSession().getSessionId(), true); } } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving recalculateMarkForSession() for sessionId: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving recalculateMarkForSession() for sessionId: " + sessionId); + } } @Override public ScratchieAnswer getScratchieAnswerByUid(Long answerUid) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getScratchieAnswerByUid() for UID: " + answerUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getScratchieAnswerByUid() for UID: " + answerUid); + } ScratchieAnswer res = (ScratchieAnswer) userManagementService.findById(ScratchieAnswer.class, answerUid); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getScratchieAnswerByUid() for UID: " + answerUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getScratchieAnswerByUid() for UID: " + answerUid); + } return res; } @Override public void setScratchingFinished(Long toolSessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered setScratchingFinished() for session ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered setScratchingFinished() for session ID: " + toolSessionId); + } ScratchieSession session = this.getScratchieSessionBySessionId(toolSessionId); session.setScratchingFinished(true); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: saving Scratchiesession uid: " + session.getUid()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: saving Scratchiesession uid: " + session.getUid()); + } scratchieSessionDao.saveObject(session); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving setScratchingFinished() for session ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving setScratchingFinished() for session ID: " + toolSessionId); + } } @Override public String finishToolSession(Long toolSessionId, Long userId) throws ScratchieApplicationException { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered finishToolSession() for user ID: " + userId + " and session ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered finishToolSession() for user ID: " + userId + " and session ID: " + toolSessionId); + } String nextUrl = null; try { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieUser by user ID: " + userId + " and session ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieUser by user ID: " + userId + " and session ID: " + toolSessionId); + } ScratchieUser user = scratchieUserDao.getUserByUserIDAndSessionID(userId, toolSessionId); user.setSessionFinished(true); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: saving ScratchieUser with user ID: " + userId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: saving ScratchieUser with user ID: " + userId); + } scratchieUserDao.saveObject(user); nextUrl = this.leaveToolSession(toolSessionId, userId); @@ -605,75 +696,100 @@ throw new ScratchieApplicationException(e); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving finishToolSession() for user ID: " + userId + " and session ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving finishToolSession() for user ID: " + userId + " and session ID: " + toolSessionId); + } return nextUrl; } @Override public ScratchieItem getScratchieItemByUid(Long itemUid) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getScratchieItemByUid(), getting ScratchieItem UID: " + itemUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getScratchieItemByUid(), getting ScratchieItem UID: " + itemUid); + } return scratchieItemDao.getByUid(itemUid); } @Override public Set getAllLeaders(Long contentId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getAllLeaders() for content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getAllLeaders() for content ID: " + contentId); + } Set leaders = new TreeSet(); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSession with content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSession with content ID: " + contentId); + } List sessionList = scratchieSessionDao.getByContentId(contentId); for (ScratchieSession session : sessionList) { ScratchieUser leader = session.getGroupLeader(); if (leader != null) { leaders.add(leader); } } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getAllLeaders() for content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getAllLeaders() for content ID: " + contentId); + } return leaders; } @Override public List getUsersBySession(Long toolSessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getUsersBySession(), getting ScratchieUsers by ScratchieSession ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log + .debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getUsersBySession(), getting ScratchieUsers by ScratchieSession ID: " + + toolSessionId); + } List res = scratchieUserDao.getBySessionID(toolSessionId); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getUsersBySession(), retrieved ScratchieUsers by ScratchieSession ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getUsersBySession(), retrieved ScratchieUsers by ScratchieSession ID: " + + toolSessionId); + } return res; } @Override public void saveUser(ScratchieUser user) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered saveUser(), saving ScratchieUser ID: " + user.getUserId()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered saveUser(), saving ScratchieUser ID: " + user.getUserId()); + } scratchieUserDao.saveObject(user); } @Override public List getMonitoringSummary(Long contentId, boolean isIncludeOnlyLeaders) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getMonitoringSummary() for content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getMonitoringSummary() for content ID: " + contentId); + } List groupSummaryList = new ArrayList(); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSessions with content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSessions with content ID: " + contentId); + } List sessionList = scratchieSessionDao.getByContentId(contentId); for (ScratchieSession session : sessionList) { Long sessionId = session.getSessionId(); - + // one new summary for one session. GroupSummary groupSummary = new GroupSummary(session); - + int totalAttempts = scratchieAnswerVisitDao.getLogCountTotal(sessionId); groupSummary.setTotalAttempts(totalAttempts); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieUsers with session ID: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieUsers with session ID: " + sessionId); + } List sessionUsers = scratchieUserDao.getBySessionID(sessionId); List usersToShow = new LinkedList(); for (ScratchieUser user : sessionUsers) { @@ -688,28 +804,36 @@ groupSummary.setUsers(usersToShow); groupSummaryList.add(groupSummary); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getMonitoringSummary() for content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getMonitoringSummary() for content ID: " + contentId); + } return groupSummaryList; } @Override public void getScratchesOrder(Collection items, Long sessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getScratchesOrder() for toolSessionId: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getScratchesOrder() for toolSessionId: " + sessionId); + } for (ScratchieItem item : items) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieAnswerVisitLogs by toolSessionId: " + sessionId - + ") and item UID: " + item.getUid()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieAnswerVisitLogs by toolSessionId: " + sessionId + ") and item UID: " + + item.getUid()); + } List itemLogs = scratchieAnswerVisitDao.getLogsBySessionAndItem(sessionId, item.getUid()); for (ScratchieAnswer answer : (Set) item.getAnswers()) { int attemptNumber; - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieAnswerVisitLog by toolSessionId: " + sessionId + " ans answer UID: " - + answer.getUid()); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + + Thread.activeCount() + "]: getting ScratchieAnswerVisitLog by toolSessionId: " + + sessionId + " ans answer UID: " + answer.getUid()); + } ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getLog(answer.getUid(), sessionId); if (log == null) { // -1 if there is no log @@ -722,15 +846,18 @@ answer.setAttemptOrder(attemptNumber); } } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getScratchesOrder() for sessionId: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getScratchesOrder() for sessionId: " + sessionId); + } } @Override public Set getItemsWithIndicatedScratches(Long toolSessionId) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getItemsWithIndicatedScratches() for session ID: " - + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getItemsWithIndicatedScratches() for session ID: " + toolSessionId); + } List userLogs = scratchieAnswerVisitDao.getLogsBySession(toolSessionId); Scratchie scratchie = this.getScratchieBySessionId(toolSessionId); @@ -759,9 +886,10 @@ boolean isItemUnraveled = this.isItemUnraveled(item, userLogs); item.setUnraveled(isItemUnraveled); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getItemsWithIndicatedScratches() for session ID: " - + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getItemsWithIndicatedScratches() for session ID: " + toolSessionId); + } return items; } @@ -836,17 +964,23 @@ @Override public List getQuestionSummary(Long contentId, Long itemUid) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getQuestionSummary() for content ID: " + contentId + " and item UID: " + itemUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getQuestionSummary() for content ID: " + contentId + " and item UID: " + itemUid); + } List groupSummaryList = new ArrayList(); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieItem by UID: " + itemUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieItem by UID: " + itemUid); + } ScratchieItem item = scratchieItemDao.getByUid(itemUid); Collection answers = item.getAnswers(); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSession by content ID: " + contentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSession by content ID: " + contentId); + } List sessionList = scratchieSessionDao.getByContentId(contentId); for (ScratchieSession session : sessionList) { Long sessionId = session.getSessionId(); @@ -864,16 +998,20 @@ answer.setAttempts(attempts); answerMap.put(dbAnswer.getUid(), answer); } - - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieAnswerVisitLog by item UID: " + itemUid); + + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieAnswerVisitLog by item UID: " + itemUid); + } List sessionAttempts = scratchieAnswerVisitDao.getLogsBySessionAndItem(sessionId, itemUid); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieUsers by session ID: " + sessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieUsers by session ID: " + sessionId); + } List users = scratchieUserDao.getBySessionID(sessionId); - + // calculate attempts table for (ScratchieUser user : users) { int attemptNumber = 0; @@ -926,8 +1064,10 @@ groupSummaryTotal.setAnswers(sortedAnswers); groupSummaryList.add(0, groupSummaryTotal); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getQuestionSummary() for content ID: " + contentId + " and item UID: " + itemUid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getQuestionSummary() for content ID: " + contentId + " and item UID: " + itemUid); + } return groupSummaryList; } @@ -989,11 +1129,15 @@ @Override public ScratchieUser getUser(Long uid) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered getUser() for UID: " + uid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered getUser() for UID: " + uid); + } ScratchieUser res = (ScratchieUser) scratchieUserDao.getObject(ScratchieUser.class, uid); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving getUser() for UID: " + uid); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving getUser() for UID: " + uid); + } return res; } @@ -1514,7 +1658,7 @@ if (logs == null) { logs = new ArrayList(); } - + for (ScratchieAnswerVisitLog log : logs) { String answer = removeHtmlMarkup(log.getScratchieAnswer().getDescription()); row[columnCount++] = new ExcelCell(answer, false); @@ -1693,11 +1837,15 @@ @Override public boolean isGroupedActivity(long toolContentID) { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered isGroupedActivity() for content ID: " + toolContentID); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered isGroupedActivity() for content ID: " + toolContentID); + } boolean res = toolService.isGroupedActivity(toolContentID); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving isGroupedActivity() for content ID: " + toolContentID); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving isGroupedActivity() for content ID: " + toolContentID); + } return res; } @@ -1917,28 +2065,38 @@ @Override public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered createToolSession() for session ID: " + toolSessionId + " and content ID: " - + toolContentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered createToolSession() for session ID: " + toolSessionId + " and content ID: " + + toolContentId); + } ScratchieSession session = new ScratchieSession(); session.setSessionId(toolSessionId); session.setSessionName(toolSessionName); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting Scratchie by content ID: " + toolContentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting Scratchie by content ID: " + toolContentId); + } Scratchie scratchie = scratchieDao.getByContentId(toolContentId); session.setScratchie(scratchie); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: creating ScratchieSession with ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: creating ScratchieSession with ID: " + toolSessionId); + } scratchieSessionDao.saveObject(session); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving createToolSession() for session ID: " + toolSessionId + " and content ID: " - + toolContentId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving createToolSession() for session ID: " + toolSessionId + " and content ID: " + + toolContentId); + } } @Override public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException { - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered leaveToolSession() for user ID: " + learnerId + " and session ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered leaveToolSession() for user ID: " + learnerId + " and session ID: " + toolSessionId); + } if (toolSessionId == null) { ScratchieServiceImpl.log.error("Fail to leave tool Session based on null tool session id."); throw new ToolException("Fail to remove tool Session based on null tool session id."); @@ -1947,26 +2105,34 @@ ScratchieServiceImpl.log.error("Fail to leave tool Session based on null learner."); throw new ToolException("Fail to remove tool Session based on null learner."); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSession with ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSession with ID: " + toolSessionId); + } ScratchieSession session = scratchieSessionDao.getSessionBySessionId(toolSessionId); if (session != null) { session.setStatus(ScratchieConstants.COMPLETED); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: saving ScratchieSession with ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: saving ScratchieSession with ID: " + toolSessionId); + } scratchieSessionDao.saveObject(session); } else { ScratchieServiceImpl.log.error("Fail to leave tool Session.Could not find shared scratchie " + "session by given session id: " + toolSessionId); throw new DataMissingException("Fail to leave tool Session." + "Could not find shared scratchie session by given session id: " + toolSessionId); } - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: calling LearnerService.completeToolSession() for user ID: " + learnerId + " and session ID: " - + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: calling LearnerService.completeToolSession() for user ID: " + learnerId + " and session ID: " + + toolSessionId); + } String res = learnerService.completeToolSession(toolSessionId, learnerId); - ScratchieServiceImpl.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving leaveToolSession() for user ID: " + learnerId + " and session ID: " + toolSessionId); + if (ScratchieServiceImpl.log.isDebugEnabled()) { + ScratchieServiceImpl.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving leaveToolSession() for user ID: " + learnerId + " and session ID: " + toolSessionId); + } return res; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java =================================================================== diff -u -r9908e067a5350bea350dea231dbe734558e67be8 -r5a56024b9d5241a08dd08252c5be795a3a024912 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 9908e067a5350bea350dea231dbe734558e67be8) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 5a56024b9d5241a08dd08252c5be795a3a024912) @@ -131,18 +131,24 @@ */ private ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ScratchieApplicationException { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered start()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered start()"); + } initializeScratchieService(); ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); final Long toolSessionId = new Long(request.getParameter(ScratchieConstants.PARAM_TOOL_SESSION_ID)); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSession by ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSession by ID: " + toolSessionId); + } ScratchieSession toolSession = LearningAction.service.getScratchieSessionBySessionId(toolSessionId); // get back the scratchie and item list and display them on page - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting Scratchi by session ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting Scratchi by session ID: " + toolSessionId); + } final Scratchie scratchie = LearningAction.service.getScratchieBySessionId(toolSessionId); final ScratchieUser user; @@ -154,9 +160,11 @@ user = getCurrentUser(toolSessionId); } - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: trying to execute checkLeaderSelectToolForSessionLeader for user ID: " + user.getUserId() - + " and session ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: trying to execute checkLeaderSelectToolForSessionLeader for user ID: " + user.getUserId() + + " and session ID: " + toolSessionId); + } final ScratchieUser groupLeader = (ScratchieUser) tryExecute(new Callable() { @Override public Object call() throws ScratchieApplicationException { @@ -168,8 +176,10 @@ if ((groupLeader == null) && !mode.isTeacher()) { // get group users and store it to request as DTO objects - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieUsers by session ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieUsers by session ID: " + toolSessionId); + } List groupUsers = LearningAction.service.getUsersBySession(toolSessionId); List groupUserDtos = new ArrayList(); for (ScratchieUser groupUser : groupUsers) { @@ -181,16 +191,20 @@ request.setAttribute(ScratchieConstants.ATTR_GROUP_USERS, groupUserDtos); request.setAttribute(ScratchieConstants.PARAM_TOOL_SESSION_ID, toolSessionId); request.setAttribute(ScratchieConstants.ATTR_SCRATCHIE, scratchie); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving start(), waiting for leader"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving start(), waiting for leader"); + } return mapping.findForward("waitforleader"); } // initial Session Map SessionMap sessionMap = new SessionMap(); request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: setting sessionMapID to " + sessionMap.getSessionID()); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: setting sessionMapID to " + sessionMap.getSessionID()); + } request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); // get notebook entry @@ -229,16 +243,20 @@ // add define later support if (scratchie.isDefineLater()) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving start()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving start()"); + } return mapping.findForward("defineLater"); } // set contentInUse flag to true! scratchie.setContentInUse(true); scratchie.setDefineLater(false); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: trying to execute saveOrUpdateScratchie() with content ID: " + scratchie.getContentId()); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: trying to execute saveOrUpdateScratchie() with content ID: " + scratchie.getContentId()); + } tryExecute(new Callable() { @Override public Object call() throws ScratchieApplicationException { @@ -253,8 +271,10 @@ // run offline support if (scratchie.getRunOffline()) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving start()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving start()"); + } return mapping.findForward("runOffline"); } @@ -272,21 +292,27 @@ // calculate whether submission deadline has passed, and if so forward to "runOffline" if (currentLearnerDate.after(tzSubmissionDeadline)) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving start()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving start()"); + } return mapping.findForward("runOffline"); } } // set scratched flag for display purpose - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieItems for session ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieItems for session ID: " + toolSessionId); + } Collection items = LearningAction.service.getItemsWithIndicatedScratches(toolSessionId); // for teacher in monitoring display the number of attempt. if (mode.isTeacher()) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting Scratches order for toolSessionId: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting Scratches order for toolSessionId: " + toolSessionId); + } LearningAction.service.getScratchesOrder(items, toolSessionId); } @@ -310,12 +336,16 @@ ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("showResults")); redirect.addParameter(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID()); redirect.addParameter(AttributeNames.ATTR_MODE, mode); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving start()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving start()"); + } return redirect; } else { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving start()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving start()"); + } return mapping.findForward(ScratchieConstants.SUCCESS); } @@ -328,36 +358,46 @@ */ private ActionForward refreshQuestionList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ScratchieApplicationException { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered refreshQuestionList()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered refreshQuestionList()"); + } initializeScratchieService(); String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: sessionMapID is " + sessionMapID); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: sessionMapID is " + sessionMapID); + } SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID); Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSession by ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSession by ID: " + toolSessionId); + } ScratchieSession toolSession = LearningAction.service.getScratchieSessionBySessionId(toolSessionId); // set scratched flag for display purpose - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieItems by session ID: " + toolSessionId - + " and putting them in sessionMap(!)"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieItems by session ID: " + toolSessionId + + " and putting them in sessionMap(!)"); + } Set items = LearningAction.service.getItemsWithIndicatedScratches(toolSessionId); sessionMap.put(ScratchieConstants.ATTR_ITEM_LIST, items); // refresh leadership status ScratchieUser user = this.getCurrentUser(toolSessionId); boolean isUserLeader = toolSession.isUserGroupLeader(user.getUid()); sessionMap.put(ScratchieConstants.ATTR_IS_USER_LEADER, isUserLeader); - + // refresh ScratchingFinished status sessionMap.put(ScratchieConstants.ATTR_IS_SCRATCHING_FINISHED, toolSession.isScratchingFinished()); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving refreshQuestionList()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving refreshQuestionList()"); + } return mapping.findForward(ScratchieConstants.SUCCESS); } @@ -366,13 +406,17 @@ */ private ActionForward isAnswerCorrect(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws JSONException, IOException { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered isAnswerCorrect()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered isAnswerCorrect()"); + } initializeScratchieService(); Long answerUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ANSWER_UID)); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieAnswer by UID: " + answerUid); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieAnswer by UID: " + answerUid); + } ScratchieAnswer answer = LearningAction.service.getScratchieAnswerByUid(answerUid); if (answer == null) { return mapping.findForward(ScratchieConstants.ERROR); @@ -383,8 +427,10 @@ response.setContentType("application/x-json;charset=utf-8"); response.getWriter().print(JSONObject); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving isAnswerCorrect()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving isAnswerCorrect()"); + } return null; } @@ -395,40 +441,52 @@ */ private ActionForward recordItemScratched(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws JSONException, IOException, ScratchieApplicationException { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered recordItemScratched()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered recordItemScratched()"); + } initializeScratchieService(); String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: sessionMapID is " + sessionMapID); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: sessionMapID is " + sessionMapID); + } SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( sessionMapID); final Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchieSession by ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchieSession by ID: " + toolSessionId); + } ScratchieSession toolSession = LearningAction.service.getScratchieSessionBySessionId(toolSessionId); ScratchieUser leader = this.getCurrentUser(toolSessionId); // only leaders are allowed to scratch answers if (!toolSession.isUserGroupLeader(leader.getUid())) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving recordItemScratched(), it is not a leader"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving recordItemScratched(), it is not a leader"); + } return null; } final Long answerUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ANSWER_UID)); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: trying to execute recordItemScratched() for leader ID: " + leader.getUserId() - + " and answer UID: " + answerUid); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: trying to execute recordItemScratched() for leader ID: " + leader.getUserId() + + " and answer UID: " + answerUid); + } tryExecute(new Callable() { @Override public Object call() throws ScratchieApplicationException { LearningAction.service.recordItemScratched(toolSessionId, answerUid); return null; } }); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving recordItemScratched()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving recordItemScratched()"); + } return null; } @@ -444,27 +502,35 @@ */ private ActionForward showResults(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ScratchieApplicationException { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered showResults()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered showResults()"); + } initializeScratchieService(); // get back SessionMap String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: sessionMapID is " + sessionMapID); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: sessionMapID is " + sessionMapID); + } SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( sessionMapID); request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID); final Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting ScratchiSession by ID " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting ScratchiSession by ID " + toolSessionId); + } ScratchieSession toolSession = LearningAction.service.getScratchieSessionBySessionId(toolSessionId); Long userUid = (Long) sessionMap.get(ScratchieConstants.ATTR_USER_UID); // in case of the leader we should let all other learners see Next Activity button if (toolSession.isUserGroupLeader(userUid)) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: trying to execute setScratchingFinished() for session ID: " + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: trying to execute setScratchingFinished() for session ID: " + toolSessionId); + } tryExecute(new Callable() { @Override public Object call() throws ScratchieApplicationException { @@ -483,8 +549,10 @@ // Create reflectList if reflection is enabled. boolean isReflectOnActivity = (Boolean) sessionMap.get(ScratchieConstants.ATTR_REFLECTION_ON); if (isReflectOnActivity) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting reflections by content ID: " + toolSession.getScratchie().getContentId()); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting reflections by content ID: " + toolSession.getScratchie().getContentId()); + } List reflections = LearningAction.service.getReflectionList(toolSession.getScratchie() .getContentId(), false); @@ -500,8 +568,10 @@ request.setAttribute(ScratchieConstants.ATTR_REFLECTIONS, reflections); } - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving showResults()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving showResults()"); + } return mapping.findForward(ScratchieConstants.SUCCESS); } @@ -516,13 +586,17 @@ */ private ActionForward finish(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: entered finish()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: entered finish()"); + } initializeScratchieService(); // get back SessionMap String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: sessionMapID is " + sessionMapID); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: sessionMapID is " + sessionMapID); + } SessionMap sessionMap = (SessionMap) request.getSession().getAttribute( sessionMapID); final Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); @@ -533,9 +607,11 @@ String nextActivityUrl = null; try { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: trying to execute finishToolSession() for user ID: " + userId + " and session ID: " - + toolSessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: trying to execute finishToolSession() for user ID: " + userId + " and session ID: " + + toolSessionId); + } nextActivityUrl = (String) tryExecute(new Callable() { @Override public Object call() throws ScratchieApplicationException { @@ -547,8 +623,10 @@ } catch (ScratchieApplicationException e) { LearningAction.log.error("Failed get next activity url:" + e.getMessage()); } - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: leaving finish()"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: leaving finish()"); + } return mapping.findForward(ScratchieConstants.SUCCESS); } @@ -559,8 +637,10 @@ for (int i = 0; i < MAX_TRANSACTION_RETRIES; i++) { try { returnValue = command.call(); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: successfully called command"); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: successfully called command"); + } break; } catch (CannotAcquireLockException e) { if (i == (MAX_TRANSACTION_RETRIES - 1)) { @@ -681,18 +761,26 @@ HttpSession ss = SessionManager.getSession(); // get back login user DTO UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting current ScratchieUser with ID: " + user.getUserID() + " and session ID: " + sessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log + .debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting current ScratchieUser with ID: " + user.getUserID() + " and session ID: " + + sessionId); + } ScratchieUser scratchieUser = LearningAction.service.getUserByIDAndSession(user.getUserID().longValue(), sessionId); if (scratchieUser == null) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting Scratchie by session ID: " + sessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting Scratchie by session ID: " + sessionId); + } ScratchieSession session = LearningAction.service.getScratchieSessionBySessionId(sessionId); final ScratchieUser newScratchieUser = new ScratchieUser(user, session); - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: creating ScratchieUser with ID: " + user.getUserID() + " and session ID: " + sessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: creating ScratchieUser with ID: " + user.getUserID() + " and session ID: " + sessionId); + } tryExecute(new Callable() { @Override public Object call() throws ScratchieApplicationException { @@ -707,8 +795,10 @@ } private ScratchieUser getSpecifiedUser(Long sessionId, Integer userId) { - LearningAction.log.info("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() - + "]: getting specified ScratchieUser with ID: " + userId + " and session ID: " + sessionId); + if (LearningAction.log.isDebugEnabled()) { + LearningAction.log.debug("LKC:[" + Thread.currentThread().getId() + "|" + Thread.activeCount() + + "]: getting specified ScratchieUser with ID: " + userId + " and session ID: " + sessionId); + } ScratchieUser scratchieUser = LearningAction.service.getUserByIDAndSession(userId.longValue(), sessionId); if (scratchieUser == null) { LearningAction.log @@ -717,5 +807,4 @@ } return scratchieUser; } - -} +} \ No newline at end of file