Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/AuthoringController.java =================================================================== diff -u --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/AuthoringController.java (revision 0) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/AuthoringController.java (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -0,0 +1,336 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.wiki.web.controller; + +import java.util.Date; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.authoring.web.AuthoringAction; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageContentDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageDTO; +import org.lamsfoundation.lams.tool.wiki.model.Wiki; +import org.lamsfoundation.lams.tool.wiki.model.WikiPage; +import org.lamsfoundation.lams.tool.wiki.model.WikiPageContent; +import org.lamsfoundation.lams.tool.wiki.model.WikiUser; +import org.lamsfoundation.lams.tool.wiki.service.IWikiService; +import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; +import org.lamsfoundation.lams.tool.wiki.util.WikiConstants; +import org.lamsfoundation.lams.tool.wiki.web.forms.AuthoringForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; + +/** + * This action handles all the authoring actions, which include opening author, saving, uploading instruction files and + * all the wikipage actions + * + * It inherits from the WikiPageAction which inherits from the LamsDispatchAction so that common actions can be used in + * learner, monitor and author + * + * @author lfoxton + */ +public class AuthoringController { + + private static Logger logger = Logger.getLogger(AuthoringController.class); + + public IWikiService wikiService; + + // Authoring SessionMap key names + private static final String KEY_TOOL_CONTENT_ID = "toolContentID"; + + private static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + + private static final String KEY_MODE = "mode"; + + /** + * Default method when no dispatch parameter is specified. It is expected that the parameter + * toolContentID will be passed in. This will be used to retrieve content for this tool. + * + */ + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + // Extract toolContentID from parameters. + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + + ToolAccessMode mode = WebUtil.readToolAccessModeAuthorDefaulted(request); + + // Set up the authForm. + AuthoringForm authForm = (AuthoringForm) form; + + Long currentPageUid = authForm.getCurrentWikiPageId(); + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + // retrieving Wiki with given toolContentID + Wiki wiki = wikiService.getWikiByContentId(toolContentID); + if (wiki == null) { + wiki = wikiService.copyDefaultContent(toolContentID); + wiki.setCreateDate(new Date()); + wikiService.saveOrUpdateWiki(wiki); + // TODO NOTE: this causes DB orphans when LD not saved. + } + + if (mode.isTeacher()) { + // Set the defineLater flag so that learners cannot use content + // while we + // are editing. This flag is released when updateContent is called. + wiki.setDefineLater(true); + wikiService.saveOrUpdateWiki(wiki); + + //audit log the teacher has started editing activity in monitor + wikiService.auditLogStartEditingActivityInMonitor(toolContentID); + } + + // update the form + updateAuthForm(authForm, wiki); + + // Set the required main wiki page + WikiPageDTO mainPageDTO = new WikiPageDTO(wiki.getMainPage()); + request.setAttribute(WikiConstants.ATTR_MAIN_WIKI_PAGE, mainPageDTO); + + // Set the current wiki page, if there is none, set to the main page + WikiPage currentWikiPage = null; + if (currentPageUid != null) { + currentWikiPage = wikiService.getWikiPageByUid(currentPageUid); + } else { + // get real instance instead of lazily initialized handler + currentWikiPage = wiki.getMainPage(); + } + WikiPageDTO currentPageDTO = new WikiPageDTO(currentWikiPage); + request.setAttribute(WikiConstants.ATTR_CURRENT_WIKI, currentPageDTO); + + // Reset the isEditable field for the form + authForm.setIsEditable(currentPageDTO.getEditable()); + + // Set the current wiki history + SortedSet currentWikiPageHistoryDTOs = new TreeSet<>(); + for (WikiPageContent wikiPageContentHistoryItem : currentWikiPage.getWikiContentVersions()) { + currentWikiPageHistoryDTOs.add(new WikiPageContentDTO(wikiPageContentHistoryItem)); + } + request.setAttribute(WikiConstants.ATTR_WIKI_PAGE_CONTENT_HISTORY, currentWikiPageHistoryDTOs); + + // Get the child wiki pages + SortedSet wikiPageDTOs = new TreeSet<>(); + for (WikiPage wikiPage : wiki.getWikiPages()) { + // check if page exists in real, not only phantom proxied object + // (happens after removing a wiki page) + wikiPage = wikiService.getWikiPageByUid(wikiPage.getUid()); + if (wikiPage != null) { + wikiPageDTOs.add(new WikiPageDTO(wikiPage)); + } + } + request.setAttribute(WikiConstants.ATTR_WIKI_PAGES, wikiPageDTOs); + + // Set up sessionMap + SessionMap map = createSessionMap(wiki, mode, contentFolderID, toolContentID); + authForm.setSessionMapID(map.getSessionID()); + + // add the sessionMap to HTTPSession. + request.getSession().setAttribute(map.getSessionID(), map); + request.setAttribute(WikiConstants.ATTR_SESSION_MAP, map); + + return mapping.findForward("success"); + } + + @Override + public ActionForward removePage(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); + Wiki wiki = wikiService.getWikiByContentId(toolContentID); + if (wiki.isDefineLater()) { + // Only mark as removed if editing a live version (monitor/live edit) + return super.removePage(mapping, form, request, response); + } + // Completely delete the page + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + WikiPage wikiPage = wikiService.getWikiPageByUid(currentPageUid); + wikiService.deleteWikiPage(wikiPage); + + // return to the main page, by setting the current page to null + return this.returnToWiki(mapping, form, request, response, null); + } + + /** + * Wrapper method to make sure that the correct wiki is returned to from the WikiPageAction class + */ + @Override + protected ActionForward returnToWiki(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response, Long currentWikiPageId) throws Exception { + AuthoringForm authForm = (AuthoringForm) form; + authForm.setCurrentWikiPageId(currentWikiPageId); + return unspecified(mapping, authForm, request, response); + } + + /** + * Implements the abstract method, since this is author we return null here as there is no user + */ + @Override + public WikiUser getCurrentUser(Long toolSessionId) { + // return null here to signify that this is in author + return null; + } + + /** + * Saves the Wiki content including uploaded files and advance options + * + * The WikiPage content is not saved here as that is done in the WikiPageAction + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + // TODO need error checking. + + // get authForm and session map. + AuthoringForm authForm = (AuthoringForm) form; + SessionMap map = getSessionMap(request, authForm); + + // get wiki content. + Wiki wiki = wikiService.getWikiByContentId((Long) map.get(AuthoringAction.KEY_TOOL_CONTENT_ID)); + + // update wiki content using form inputs + updateWiki(wiki, authForm); + + // set the update date + wiki.setUpdateDate(new Date()); + + // releasing defineLater flag so that learner can start using the tool. + wiki.setDefineLater(false); + + wikiService.saveOrUpdateWiki(wiki); + + request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); + + // add the sessionMapID to form + authForm.setSessionMapID(map.getSessionID()); + + request.setAttribute(WikiConstants.ATTR_SESSION_MAP, map); + + return mapping.findForward("success"); + } + + /** + * Updates Wiki content using AuthoringForm inputs. + * + * @param authForm + * @param mode + * @return + */ + private void updateWiki(Wiki wiki, AuthoringForm authForm) { + // wiki.setTitle(authForm.getTitle()); + WikiPage mainPage = wiki.getMainPage(); + // mainPage.setTitle(authForm.getTitle()); + + WikiPageContent content = mainPage.getCurrentWikiContent(); + // content.setBody(authForm.getWikiBody()); + // mainPage.setCurrentWikiContent(content); + + wiki.setMainPage(mainPage); + wiki.setLockOnFinished(authForm.isLockOnFinished()); + wiki.setAllowLearnerAttachImages(authForm.isAllowLearnerAttachImages()); + wiki.setAllowLearnerCreatePages(authForm.isAllowLearnerCreatePages()); + wiki.setAllowLearnerInsertLinks(authForm.isAllowLearnerInsertLinks()); + wiki.setReflectOnActivity(authForm.isReflectOnActivity()); + wiki.setReflectInstructions(authForm.getReflectInstructions()); + wiki.setNotifyUpdates(authForm.isNotifyUpdates()); + wiki.setMaximumEdits(authForm.getMaximumEdits()); + wiki.setMinimumEdits(authForm.getMinimumEdits()); + } + + /** + * Updates AuthoringForm using Wiki content. + * + * @param wiki + * @param authForm + * @return + */ + private void updateAuthForm(AuthoringForm authForm, Wiki wiki) { + authForm.setLockOnFinished(wiki.isLockOnFinished()); + authForm.setAllowLearnerAttachImages(wiki.isAllowLearnerAttachImages()); + authForm.setAllowLearnerCreatePages(wiki.isAllowLearnerCreatePages()); + authForm.setAllowLearnerInsertLinks(wiki.isAllowLearnerInsertLinks()); + authForm.setReflectOnActivity(wiki.isReflectOnActivity()); + authForm.setReflectInstructions(wiki.getReflectInstructions()); + authForm.setMaximumEdits(wiki.getMaximumEdits()); + authForm.setMinimumEdits(wiki.getMinimumEdits()); + authForm.setNewPageIsEditable(true); + authForm.setNotifyUpdates(wiki.isNotifyUpdates()); + } + + /** + * Updates SessionMap using Wiki content. + * + * @param wiki + * @param mode + */ + private SessionMap createSessionMap(Wiki wiki, ToolAccessMode mode, String contentFolderID, + Long toolContentID) { + + SessionMap map = new SessionMap<>(); + + map.put(AuthoringController.KEY_MODE, mode); + map.put(AuthoringController.KEY_CONTENT_FOLDER_ID, contentFolderID); + map.put(AuthoringController.KEY_TOOL_CONTENT_ID, toolContentID); + + return map; + } + + /** + * Retrieve the SessionMap from the HttpSession. + * + * @param request + * @param authForm + * @return + */ + private SessionMap getSessionMap(HttpServletRequest request, AuthoringForm authForm) { + return (SessionMap) request.getSession().getAttribute(authForm.getSessionMapID()); + } +} Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/LearningAction.java =================================================================== diff -u --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/LearningAction.java (revision 0) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/LearningAction.java (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -0,0 +1,405 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.wiki.web.controller; + +import java.io.IOException; +import java.util.Date; +import java.util.TimeZone; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.learning.web.util.LearningWebUtil; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.ToolSessionManager; + +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.wiki.dto.WikiDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageContentDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiUserDTO; +import org.lamsfoundation.lams.tool.wiki.model.Wiki; +import org.lamsfoundation.lams.tool.wiki.model.WikiPage; +import org.lamsfoundation.lams.tool.wiki.model.WikiPageContent; +import org.lamsfoundation.lams.tool.wiki.model.WikiSession; +import org.lamsfoundation.lams.tool.wiki.model.WikiUser; +import org.lamsfoundation.lams.tool.wiki.service.IWikiService; +import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; +import org.lamsfoundation.lams.tool.wiki.util.WikiConstants; +import org.lamsfoundation.lams.tool.wiki.util.WikiException; +import org.lamsfoundation.lams.tool.wiki.web.forms.LearningForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.util.DateUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * This action handles all the learning actions, which include opening learner, + * relection, going to the next activity, and all the wikipage actions + * + * It inherits from the WikiPageAction which inherits from the + * LamsDispatchAction so that common actions can be used in learner, monitor and + * author + * + * @author lfoxton + * @version + * + * + * + * + * + * + * + * + */ +public class LearningAction extends WikiPageAction { + + private static Logger log = Logger.getLogger(LearningAction.class); + + private static final boolean MODE_OPTIONAL = false; + + private IWikiService wikiService; + + /** + * unspecified loads the learner window with the current wiki page as well + * as setting all the advanced options and user-specifice info + */ + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + LearningForm learningForm = (LearningForm) form; + + // 'toolSessionID' and 'mode' parameters are expected to be present. + // TODO need to catch exceptions and handle errors. + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, MODE_OPTIONAL); + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + + Long currentPageUid = learningForm.getCurrentWikiPageId(); + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + // Retrieve the session and content. + WikiSession wikiSession = wikiService.getSessionBySessionId(toolSessionID); + if (wikiSession == null) { + throw new WikiException("Cannot retrieve session with toolSessionID" + toolSessionID); + } + + Wiki wiki = wikiSession.getWiki(); + + // check defineLater + if (wiki.isDefineLater()) { + return mapping.findForward("defineLater"); + } + + // set mode, toolSessionID and WikiDTO + request.setAttribute(WikiConstants.ATTR_MODE, mode.toString()); + learningForm.setToolSessionID(toolSessionID); + + WikiDTO wikiDTO = new WikiDTO(wiki); + request.setAttribute(WikiConstants.ATTR_WIKI_DTO, wikiDTO); + + // Set the content in use flag. + if (!wiki.isContentInUse()) { + wiki.setContentInUse(new Boolean(true)); + wikiService.saveOrUpdateWiki(wiki); + } + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionID, request, + getServlet().getServletContext()); + + // get the user + WikiUser wikiUser; + if (mode.equals(ToolAccessMode.TEACHER)) { + Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); + wikiUser = wikiService.getUserByUserIdAndSessionId(userID, toolSessionID); + } else { + wikiUser = getCurrentUser(toolSessionID); + } + + // Create the userDTO + WikiUserDTO wikiUserDTO = new WikiUserDTO(wikiUser); + if (wikiUser.isFinishedActivity()) { + // get the notebook entry. + NotebookEntry notebookEntry = wikiService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + WikiConstants.TOOL_SIGNATURE, wikiUser.getUserId().intValue()); + if (notebookEntry != null) { + wikiUserDTO.setNotebookEntry(notebookEntry.getEntry()); + } + } + + // Set whether the user has enabled notifications + if (wikiService.getEventNotificationService().eventExists(WikiConstants.TOOL_SIGNATURE, + WikiConstants.EVENT_NOTIFY_LEARNERS, toolSessionID) + && wikiService.getEventNotificationService().isSubscribed(WikiConstants.TOOL_SIGNATURE, + WikiConstants.EVENT_NOTIFY_LEARNERS, toolSessionID, wikiUser.getUserId())) { + wikiUserDTO.setNotificationEnabled(true); + } + + + + + // add the userDTO to attributes + request.setAttribute(WikiConstants.ATTR_USER_DTO, wikiUserDTO); + + // Set whether user has reached maximum edits + int maxEdits = wiki.getMaximumEdits(); + Boolean maxEditsReached = (maxEdits != 0 && wikiUser.getWikiEdits() >= maxEdits); + request.setAttribute(WikiConstants.ATTR_MAX_EDITS_REACHED, maxEditsReached); + request.setAttribute(WikiConstants.ATTR_EDITS_LEFT, maxEdits - wikiUser.getWikiEdits()); + + // Set whether user has reached minimum edits + int minEdits = wiki.getMinimumEdits(); + Boolean minEditsReached = (wikiUser.getWikiEdits() >= minEdits); + request.setAttribute(WikiConstants.ATTR_MIN_EDITS_REACHED, minEditsReached); + + // Get the wikipages from the session and the main page + SortedSet wikiPageDTOs = new TreeSet(); + for (WikiPage wikiPage : wikiSession.getWikiPages()) { + WikiPageDTO pageDTO = new WikiPageDTO(wikiPage); + + wikiPageDTOs.add(pageDTO); + + } + request.setAttribute(WikiConstants.ATTR_WIKI_PAGES, wikiPageDTOs); + request.setAttribute(WikiConstants.ATTR_MAIN_WIKI_PAGE, new WikiPageDTO(wikiSession.getMainPage())); + + // Set the current wiki page, if there is none, set to the main page + WikiPage currentWikiPage = null; + if (currentPageUid != null) { + currentWikiPage = wikiService.getWikiPageByUid(currentPageUid); + } else { + currentWikiPage = wikiSession.getMainPage(); + } + request.setAttribute(WikiConstants.ATTR_CURRENT_WIKI, new WikiPageDTO(currentWikiPage)); + + // Set the current wiki history + SortedSet currentWikiPageHistoryDTOs = new TreeSet(); + for (WikiPageContent wikiPageContentHistoryItem : currentWikiPage.getWikiContentVersions()) { + currentWikiPageHistoryDTOs.add(new WikiPageContentDTO(wikiPageContentHistoryItem)); + } + request.setAttribute(WikiConstants.ATTR_WIKI_PAGE_CONTENT_HISTORY, currentWikiPageHistoryDTOs); + + // Set the content folder id + request.setAttribute(WikiConstants.ATTR_CONTENT_FOLDER_ID, + wikiService.getLearnerContentFolder(toolSessionID, wikiUser.getUserId())); + + // set readOnly flag. + if (mode.equals(ToolAccessMode.TEACHER) || (wiki.isLockOnFinished() && wikiUser.isFinishedActivity())) { + request.setAttribute(WikiConstants.ATTR_CONTENT_EDITAVLE, false); + } else { + request.setAttribute(WikiConstants.ATTR_CONTENT_EDITAVLE, true); + } + request.setAttribute(WikiConstants.ATTR_FINISHED_ACTIVITY, wikiUser.isFinishedActivity()); + + + /* Check if submission deadline is null */ + + Date submissionDeadline = wikiDTO.getSubmissionDeadline(); + request.setAttribute("wikiDTO", wikiDTO); + + + if (submissionDeadline != null) { + + HttpSession ss = SessionManager.getSession(); + UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone learnerTimeZone = learnerDto.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); + Date currentLearnerDate = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, new Date()); + request.setAttribute("submissionDeadline", submissionDeadline); + + // calculate whether submission deadline has passed, and if so forward to "submissionDeadline" + if (currentLearnerDate.after(tzSubmissionDeadline)) { + return mapping.findForward("submissionDeadline"); + } + + } + + return mapping.findForward("wiki"); + } + + /** + * Wrapper method to make sure that the correct wiki is returned to from the + * WikiPageAction class + */ + @Override + protected ActionForward returnToWiki(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response, Long currentWikiPageId) throws Exception { + LearningForm learnForm = (LearningForm) form; + learnForm.setCurrentWikiPageId(currentWikiPageId); + // put the tool session id in the attributes so that the progress bar can pick it up. + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, learnForm.getToolSessionID()); + return unspecified(mapping, learnForm, request, response); + } + + /** + * Gets the current user by toolSessionId + * + * @param toolSessionId + */ + @Override + protected WikiUser getCurrentUser(Long toolSessionId) { + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + // attempt to retrieve user using userId and toolSessionId + WikiUser wikiUser = wikiService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), + toolSessionId); + + if (wikiUser == null) { + WikiSession wikiSession = wikiService.getSessionBySessionId(toolSessionId); + wikiUser = wikiService.createWikiUser(user, wikiSession); + } + + return wikiUser; + } + + /** + * Finish the activity, we dont need to save anything here, as that is done + * by the wikipage actions + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long toolSessionID = WebUtil.readLongParam(request, "toolSessionID"); + + WikiUser wikiUser = getCurrentUser(toolSessionID); + + if (wikiUser != null) { + wikiUser.setFinishedActivity(true); + wikiService.saveOrUpdateWikiUser(wikiUser); + } else { + log.error("finishActivity(): couldn't find WikiUser with id: " + wikiUser.getUserId() + + "and toolSessionID: " + toolSessionID); + } + + ToolSessionManager sessionMgrService = WikiServiceProxy.getWikiSessionManager(getServlet().getServletContext()); + + String nextActivityUrl; + try { + nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, wikiUser.getUserId()); + response.sendRedirect(nextActivityUrl); + } catch (DataMissingException e) { + throw new WikiException(e); + } catch (ToolException e) { + throw new WikiException(e); + } catch (IOException e) { + throw new WikiException(e); + } + + return null; // TODO need to return proper page. + } + + /** + * Opens the notebook page for reflections + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + LearningForm lrnForm = (LearningForm) form; + + // set the finished flag + WikiUser wikiUser = this.getCurrentUser(lrnForm.getToolSessionID()); + WikiDTO wikiDTO = new WikiDTO(wikiUser.getWikiSession().getWiki()); + + request.setAttribute("wikiDTO", wikiDTO); + + NotebookEntry notebookEntry = wikiService.getEntry(wikiUser.getWikiSession().getSessionId(), + CoreNotebookConstants.NOTEBOOK_TOOL, WikiConstants.TOOL_SIGNATURE, wikiUser.getUserId().intValue()); + + if (notebookEntry != null) { + lrnForm.setEntryText(notebookEntry.getEntry()); + } + + LearningWebUtil.putActivityPositionInRequestByToolSessionId(lrnForm.getToolSessionID(), request, + getServlet().getServletContext()); + + return mapping.findForward("notebook"); + } + + /** + * Submit reflections + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + // save the reflection entry and call the notebook. + + LearningForm lrnForm = (LearningForm) form; + + WikiUser wikiUser = this.getCurrentUser(lrnForm.getToolSessionID()); + Long toolSessionID = wikiUser.getWikiSession().getSessionId(); + Integer userID = wikiUser.getUserId().intValue(); + + // check for existing notebook entry + NotebookEntry entry = wikiService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + WikiConstants.TOOL_SIGNATURE, userID); + + if (entry == null) { + // create new entry + wikiService.createNotebookEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, + WikiConstants.TOOL_SIGNATURE, userID, lrnForm.getEntryText()); + } else { + // update existing entry + entry.setEntry(lrnForm.getEntryText()); + entry.setLastModified(new Date()); + wikiService.updateEntry(entry); + } + + return finishActivity(mapping, form, request, response); + } +} Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/MonitoringAction.java =================================================================== diff -u --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/MonitoringAction.java (revision 0) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/MonitoringAction.java (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -0,0 +1,287 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.wiki.web.controller; + +import java.io.IOException; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; +import org.lamsfoundation.lams.tool.wiki.dto.WikiDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageContentDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiSessionDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiUserDTO; +import org.lamsfoundation.lams.tool.wiki.model.Wiki; +import org.lamsfoundation.lams.tool.wiki.model.WikiPage; +import org.lamsfoundation.lams.tool.wiki.model.WikiPageContent; +import org.lamsfoundation.lams.tool.wiki.model.WikiSession; +import org.lamsfoundation.lams.tool.wiki.model.WikiUser; +import org.lamsfoundation.lams.tool.wiki.service.IWikiService; +import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; +import org.lamsfoundation.lams.tool.wiki.util.WikiConstants; +import org.lamsfoundation.lams.tool.wiki.util.WikiException; +import org.lamsfoundation.lams.tool.wiki.web.forms.MonitoringForm; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; + +import java.util.Date; + +import org.lamsfoundation.lams.util.DateUtil; + +import java.util.TimeZone; + +/** + * This action handles all the monitoring actions, which include opening + * monitor, and all the wikipage actions + * + * It inherits from the WikiPageAction which inherits from the + * LamsDispatchAction so that common actions can be used in learner, monitor and + * author + * + * @author lfoxton + */ +public class MonitoringAction extends WikiPageAction { + + private static Logger log = Logger.getLogger(MonitoringAction.class); + + public IWikiService wikiService; + + /** + * Sets up the main authoring page which lists the tool sessions and allows + * you to view their respective WikiPages + */ + @Override + public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws Exception { + + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID, true); + Wiki wiki; + //toolContentID is null in case request comes from WikiPageAction.revertPage() + if (toolContentID == null) { + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + WikiSession session = wikiService.getSessionBySessionId(toolSessionID); + wiki = session.getWiki(); + toolContentID = wiki.getToolContentId(); + + } else { + wiki = wikiService.getWikiByContentId(toolContentID); + } + + if (wiki == null) { + throw new WikiException("Could not find wiki with content id: " + toolContentID); + } + + WikiDTO wikiDT0 = new WikiDTO(wiki); + + Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true); + wikiDT0.setCurrentTab(currentTab); + + /* Check if submission deadline is null */ + + Date submissionDeadline = wikiDT0.getSubmissionDeadline(); + + if (submissionDeadline != null) { + + HttpSession ss = SessionManager.getSession(); + UserDTO learnerDto = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone learnerTimeZone = learnerDto.getTimeZone(); + Date tzSubmissionDeadline = DateUtil.convertToTimeZoneFromDefault(learnerTimeZone, submissionDeadline); + request.setAttribute("submissionDeadline", tzSubmissionDeadline.getTime()); + // use the unconverted time, as convertToStringForJSON() does the timezone conversion if needed + request.setAttribute("submissionDateString", DateUtil.convertToStringForJSON(submissionDeadline, request.getLocale())); + + + } + + request.setAttribute(WikiConstants.ATTR_WIKI_DTO, wikiDT0); + request.setAttribute(WikiConstants.ATTR_CONTENT_FOLDER_ID, contentFolderID); + request.setAttribute(WikiConstants.ATTR_IS_GROUPED_ACTIVITY, wikiService.isGroupedActivity(toolContentID)); + return mapping.findForward("success"); + } + + /** + * Wrapper method to make sure that the correct wiki is returned to from the + * WikiPageAction class + */ + @Override + protected ActionForward returnToWiki(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response, Long currentWikiPageId) throws Exception { + MonitoringForm monitoringForm = (MonitoringForm) form; + monitoringForm.setCurrentWikiPageId(currentWikiPageId); + return showWiki(mapping, monitoringForm, request, response); + } + + /** + * Gets the current user by toolSessionId + * + * @param toolSessionId + */ + @Override + protected WikiUser getCurrentUser(Long toolSessionId) { + UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER); + + // attempt to retrieve user using userId and toolSessionId + WikiUser wikiUser = wikiService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), + toolSessionId); + + if (wikiUser == null) { + WikiSession wikiSession = wikiService.getSessionBySessionId(toolSessionId); + wikiUser = wikiService.createWikiUser(user, wikiSession); + } + + return wikiUser; + } + + + /** + * Set Submission Deadline + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward setSubmissionDeadline(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws IOException { + + // set up wikiService + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + Long contentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Wiki wiki = wikiService.getWikiByContentId(contentID); + + Long dateParameter = WebUtil.readLongParam(request,WikiConstants.ATTR_SUBMISSION_DEADLINE, true); + Date tzSubmissionDeadline = null; + String formattedDate = ""; + if (dateParameter != null) { + Date submissionDeadline = new Date(dateParameter); + HttpSession ss = SessionManager.getSession(); + UserDTO teacher = (UserDTO) ss.getAttribute(AttributeNames.USER); + TimeZone teacherTimeZone = teacher.getTimeZone(); + tzSubmissionDeadline = DateUtil.convertFromTimeZoneToDefault(teacherTimeZone, submissionDeadline); + formattedDate = DateUtil.convertToStringForJSON(tzSubmissionDeadline, request.getLocale()); + } + wiki.setSubmissionDeadline(tzSubmissionDeadline); + wikiService.saveOrUpdateWiki(wiki); + response.setContentType("text/plain;charset=utf-8"); + response.getWriter().print(formattedDate); + return null; + } + + /** + * Shows a specific wiki based on the session id + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + public ActionForward showWiki(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + Long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); + String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + + WikiSession wikiSession = wikiService.getSessionBySessionId(toolSessionId); + WikiSessionDTO sessionDTO = new WikiSessionDTO(wikiSession); + Long toolContentId = wikiSession.getWiki().getToolContentId(); + + // Add all the user notebook entries to the session dto + for (WikiUserDTO userDTO : sessionDTO.getUserDTOs()) { + NotebookEntry notebookEntry = wikiService.getEntry(toolSessionId, CoreNotebookConstants.NOTEBOOK_TOOL, + WikiConstants.TOOL_SIGNATURE, userDTO.getUserId().intValue()); + if (notebookEntry != null) { + userDTO.setNotebookEntry(notebookEntry.getEntry()); + } + sessionDTO.getUserDTOs().add(userDTO); + } + request.setAttribute(WikiConstants.ATTR_SESSION_DTO, sessionDTO); + + // Set up the authForm. + MonitoringForm monForm = (MonitoringForm) form; + + Long currentPageUid = monForm.getCurrentWikiPageId(); + + // Get the wikipages from the session and the main page + SortedSet wikiPageDTOs = new TreeSet(); + for (WikiPage wikiPage : wikiSession.getWikiPages()) { + WikiPageDTO pageDTO = new WikiPageDTO(wikiPage); + + wikiPageDTOs.add(pageDTO); + } + + request.setAttribute(WikiConstants.ATTR_WIKI_PAGES, wikiPageDTOs); + request.setAttribute(WikiConstants.ATTR_MAIN_WIKI_PAGE, new WikiPageDTO(wikiSession.getMainPage())); + + // Set the current wiki page, if there is none, set to the main page + WikiPage currentWikiPage = null; + if (currentPageUid != null) { + currentWikiPage = wikiService.getWikiPageByUid(currentPageUid); + } else { + currentWikiPage = wikiSession.getMainPage(); + } + request.setAttribute(WikiConstants.ATTR_CURRENT_WIKI, new WikiPageDTO(currentWikiPage)); + + // Reset the isEditable and newPageIdEditable field for the form + monForm.setIsEditable(currentWikiPage.getEditable()); + monForm.setNewPageIsEditable(true); + + // Set the current wiki history + SortedSet currentWikiPageHistoryDTOs = new TreeSet(); + for (WikiPageContent wikiPageContentHistoryItem : currentWikiPage.getWikiContentVersions()) { + currentWikiPageHistoryDTOs.add(new WikiPageContentDTO(wikiPageContentHistoryItem)); + } + request.setAttribute(WikiConstants.ATTR_WIKI_PAGE_CONTENT_HISTORY, currentWikiPageHistoryDTOs); + request.setAttribute(WikiConstants.ATTR_CONTENT_FOLDER_ID, contentFolderID); + request.setAttribute(WikiConstants.ATTR_IS_GROUPED_ACTIVITY, wikiService.isGroupedActivity(toolContentId)); + + return mapping.findForward("wiki_display"); + } +} Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/PedagogicalPlannerAction.java =================================================================== diff -u --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/PedagogicalPlannerAction.java (revision 0) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/PedagogicalPlannerAction.java (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -0,0 +1,105 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + + +package org.lamsfoundation.lams.tool.wiki.web.controller; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.tool.wiki.model.Wiki; +import org.lamsfoundation.lams.tool.wiki.model.WikiPage; +import org.lamsfoundation.lams.tool.wiki.service.IWikiService; +import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; +import org.lamsfoundation.lams.tool.wiki.web.forms.WikiPedagogicalPlannerForm; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; + +/** + * @author Marcin Cieslak + * + * + * + * + * + */ +public class PedagogicalPlannerAction extends LamsDispatchAction { + + private static Logger logger = Logger.getLogger(PedagogicalPlannerAction.class); + + public IWikiService wikiService; + + @Override + protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + return initPedagogicalPlannerForm(mapping, form, request, response); + } + + public ActionForward initPedagogicalPlannerForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + WikiPedagogicalPlannerForm plannerForm = (WikiPedagogicalPlannerForm) form; + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + Wiki wiki = getWikiService().getWikiByContentId(toolContentID); + plannerForm.fillForm(wiki); + String contentFolderId = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + plannerForm.setContentFolderID(contentFolderId); + return mapping.findForward("success"); + } + + public ActionForward saveOrUpdatePedagogicalPlannerForm(ActionMapping mapping, ActionForm form, + HttpServletRequest request, HttpServletResponse response) throws IOException { + WikiPedagogicalPlannerForm plannerForm = (WikiPedagogicalPlannerForm) form; +// ActionMessages errors = plannerForm.validate(); +// if (errors.isEmpty()) { +// String instructions = plannerForm.getWikiBody(); +// Long toolContentID = plannerForm.getToolContentID(); +// Wiki wiki = getWikiService().getWikiByContentId(toolContentID); +// WikiPage wikiPage = wiki.getWikiPages().iterator().next(); +// wikiPage.setTitle(plannerForm.getTitle()); +// wikiPage.getCurrentWikiContent().setBody(plannerForm.getWikiBody()); +// getWikiService().saveOrUpdateWikiPage(wikiPage); +// } else { +// saveErrors(request, errors); +// } + return mapping.findForward("success"); + } + + private IWikiService getWikiService() { + if (wikiService == null) { + wikiService = WikiServiceProxy.getWikiService(this.getServlet().getServletContext()); + } + return wikiService; + } + +} \ No newline at end of file Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/WikiPageController.java =================================================================== diff -u --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/WikiPageController.java (revision 0) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/controller/WikiPageController.java (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -0,0 +1,509 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.wiki.web.controller; + +import java.util.List; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionForward; +import org.apache.struts.action.ActionMapping; +import org.lamsfoundation.lams.events.IEventNotificationService; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageContentDTO; +import org.lamsfoundation.lams.tool.wiki.dto.WikiPageDTO; +import org.lamsfoundation.lams.tool.wiki.model.Wiki; +import org.lamsfoundation.lams.tool.wiki.model.WikiPage; +import org.lamsfoundation.lams.tool.wiki.model.WikiPageContent; +import org.lamsfoundation.lams.tool.wiki.model.WikiSession; +import org.lamsfoundation.lams.tool.wiki.model.WikiUser; +import org.lamsfoundation.lams.tool.wiki.service.IWikiService; +import org.lamsfoundation.lams.tool.wiki.service.WikiServiceProxy; +import org.lamsfoundation.lams.tool.wiki.util.WikiConstants; +import org.lamsfoundation.lams.tool.wiki.web.forms.WikiPageForm; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.Configuration; +import org.lamsfoundation.lams.util.ConfigurationKeys; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.context.WebApplicationContext; + +/** + * An abstract class used for wiki actions common to monitor, learner and author + * + * @author lfoxton + * + */ +@Controller +public abstract class WikiPageController { + + private static Logger logger = Logger.getLogger(AuthoringController.class); + + @Autowired + @Qualifier("wikiService") + private IWikiService wikiService; + + @Autowired + private WebApplicationContext applicationContext; + + /** + * Default method when no dispatch parameter is specified. + */ + @Override + protected abstract String unspecified(WikiPageForm wikiForm, HttpServletRequest request) throws Exception; + + /** + * This action returns to the current wiki by updating the form accordingly + */ + protected abstract String returnToWiki(WikiPageForm wikiForm, HttpServletRequest request, Long currentWikiPageId) + throws Exception; + + protected abstract WikiUser getCurrentUser(Long toolSessionId); + + /** + * Edit a page and make a new page content entry + */ + @RequestMapping("/editPage") + public String editPage(@ModelAttribute WikiPageForm wikiForm, HttpServletRequest request) throws Exception { + + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Set up the wiki form + revertJavascriptTokenReplacement(wikiForm); + + // Get the current wiki page + WikiPage currentPage = wikiService.getWikiPageByUid(currentPageUid); + + // Check if the content is different + if (!currentPage.getCurrentWikiContent().getBody().equals(wikiForm.getWikiBody()) + || !currentPage.getTitle().equals(wikiForm.getTitle())) { + + // Set up the wiki user if this is a tool session (learner) + // Also set the editable flag here + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + WikiUser user = null; + if (toolSessionID != null) { + user = this.getCurrentUser(toolSessionID); + } + + // Setting the editable flag based on call origin + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); + if ((mode == null) || (mode == ToolAccessMode.TEACHER)) { + + // Author/Monitor/Live edit + // If no editable flag came in the form (as in learner), set + // false + if (wikiForm.getIsEditable() == null) { + wikiForm.setIsEditable(false); + } + } else { + // Learner or preview If no editable flag came in the form + // (as in learner), set true + if (wikiForm.getIsEditable() == null) { + wikiForm.setIsEditable(true); + } + } + // Updating the wikiPage, setting a null user which indicated + // this change was made in author + wikiService.updateWikiPage(wikiForm, currentPage, user); + + // Send edit notifications + if ((toolSessionID != null) && (user != null)) { + notifyWikiChange(toolSessionID, "notify.pageEdited.subject", "notify.pageEdited.body", user, request); + } + + } + + // Make sure the current page is set correctly then return to the wiki + return returnToWiki(wikiForm, request, currentPageUid); + } + + /** + * Revert to a previous page content in the page history + */ + @RequestMapping("/revertPage") + public String revertPage(@ModelAttribute WikiPageForm wikiForm, HttpServletRequest request) throws Exception { + Long revertPageContentVersion = new Long( + WebUtil.readLongParam(request, WikiConstants.ATTR_HISTORY_PAGE_CONTENT_ID)); + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Get the current wiki page + WikiPage currentPage = wikiService.getWikiPageByUid(currentPageUid); + + // Set up the wiki user if this is a tool session (learner) + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + WikiUser user = null; + if (toolSessionID != null) { + user = this.getCurrentUser(toolSessionID); + } + + WikiPageContent content = wikiService.getWikiPageContent(revertPageContentVersion); + + // Set the wiki body in the authform + wikiForm.setWikiBody(content.getBody()); + wikiForm.setIsEditable(currentPage.getEditable()); + + // Updating the wikiPage, setting a null user which indicated this + // change was made in author + wikiService.updateWikiPage(wikiForm, currentPage, user); + + // Send revert notifications + if ((toolSessionID != null) && (user != null)) { + notifyWikiChange(toolSessionID, "notify.pageEdited.subject", "notify.pageEdited.body", user, request); + + // put the tool session id in the attributes so that the progress bar can pick it up. + request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionID); + } + + return unspecified(wikiForm, request); + } + + /** + * Compare two page content history items and return the result + */ + @RequestMapping("/comparePage") + public String comparePage(HttpServletRequest request) throws Exception { + + Long revertPageContentVersion = new Long( + WebUtil.readLongParam(request, WikiConstants.ATTR_HISTORY_PAGE_CONTENT_ID)); + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Get the current wiki page content + WikiPage currentWikiPage = wikiService.getWikiPageByUid(currentPageUid); + WikiPageContent currentContent = currentWikiPage.getCurrentWikiContent(); + + // Get the old wiki content to compare + WikiPageContent compareContent = wikiService.getWikiPageContent(revertPageContentVersion); + + // Do the compariason + String diff = wikiService.comparePages(compareContent.getBody(), currentContent.getBody()); + + request.setAttribute(WikiConstants.ATTR_COMPARE_VERSIONS, + compareContent.getVersion().toString() + "-" + currentContent.getVersion().toString()); + request.setAttribute(WikiConstants.ATTR_COMPARE_TITLE, currentWikiPage.getTitle()); + request.setAttribute(WikiConstants.ATTR_COMPARE_STRING, diff); + + return "pages/wiki/compare"; + } + + /** + * View a page content from a wiki page's history + */ + @RequestMapping("/viewPage") + public String viewPage(HttpServletRequest request) throws Exception { + Long revertPageContentVersion = new Long( + WebUtil.readLongParam(request, WikiConstants.ATTR_HISTORY_PAGE_CONTENT_ID)); + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Get the current wiki page content + WikiPage currentWikiPage = wikiService.getWikiPageByUid(currentPageUid); + + // Get the old wiki content + WikiPageContent oldContent = wikiService.getWikiPageContent(revertPageContentVersion); + + // Set up the dto, only need to set title and content, as this is a view + WikiPageDTO pageDTO = new WikiPageDTO(); + pageDTO.setTitle(currentWikiPage.getTitle()); + pageDTO.setCurrentWikiContentDTO(new WikiPageContentDTO(oldContent)); + + request.setAttribute(WikiConstants.ATTR_CURRENT_WIKI, pageDTO); + + return "pages/wiki/viewWiki"; + } + + /** + * Change the active page of the wiki form + */ + @RequestMapping("/changePage") + public String changePage(@ModelAttribute WikiPageForm wikiForm, HttpServletRequest request) throws Exception { + + Wiki wiki = null; + WikiSession session = null; + WikiPage wikiPage = null; + + String newPageName = WebUtil.readStrParam(request, WikiConstants.ATTR_NEW_PAGE_NAME).replaceAll("`", "'"); + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + + // get the wiki by either toolContentId or tool session + if (toolSessionID == null) { + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + wiki = wikiService.getWikiByContentId(toolContentID); + + // Get the page to change to + wikiPage = wikiService.getWikiPageByWikiAndTitle(wiki, newPageName); + } else { + session = wikiService.getSessionBySessionId(toolSessionID); + wiki = session.getWiki(); + + // Get the page to change to + wikiPage = wikiService.getWikiBySessionAndTitle(session, newPageName); + } + + if (wikiPage == null) { + // TODO: Error handling page does not exist + } + + // go through unspecified to display the author screen, using wrapper + // method to set the current page + return this.returnToWiki(wikiForm, request, wikiPage.getUid()); + } + + /** + * Add a new wiki page to this wiki instance + */ + @RequestMapping("/addPage") + public String addPage(@ModelAttribute WikiPageForm wikiForm, HttpServletRequest request) throws Exception { + + Wiki wiki = null; + WikiSession session = null; + WikiUser user = null; + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + + // Set up the authoring form + revertJavascriptTokenReplacement(wikiForm); + + // get the wiki by either toolContentId or tool session + if (toolSessionID == null) { + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID); + wiki = wikiService.getWikiByContentId(toolContentID); + // If no editable flag came in the form (as in learner), set true + if (wikiForm.getNewPageIsEditable() == null) { + wikiForm.setNewPageIsEditable(false); + } + } else { + session = wikiService.getSessionBySessionId(toolSessionID); + wiki = session.getWiki(); + user = getCurrentUser(toolSessionID); + + } + + // Setting the editable flag based on call origin + ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true); + if ((mode == null) || (mode == ToolAccessMode.TEACHER)) { + // Author/Monitor/Live edit + // If no editable flag came in the form (as in learner), set false + if (wikiForm.getNewPageIsEditable() == null) { + wikiForm.setNewPageIsEditable(false); + } + } else { + // Learner or preview + // If no editable flag came in the form (as in learner), set true + if (wikiForm.getNewPageIsEditable() == null) { + wikiForm.setNewPageIsEditable(true); + } + } + + // inserting the wiki page, null user and session indicates that this + // page was saved in author + Long currentPageUid = wikiService.insertWikiPage(wikiForm, wiki, user, session); + + // Send adding page notifications + if ((toolSessionID != null) && (user != null)) { + notifyWikiChange(toolSessionID, "notify.pageAdded.subject", "notify.pageAdded.body", user, request); + } + + // go to the new wiki page + return returnToWiki(wikiForm, request, currentPageUid); + } + + /** + * Remove a wiki page from the wiki instance + */ + @RequestMapping("/removePage") + public String removePage(@ModelAttribute WikiPageForm wikiForm, HttpServletRequest request) throws Exception { + // The page to be removed + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Get the session information for notifications + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + WikiUser user = getCurrentUser(toolSessionID); + + WikiPage wikiPage = wikiService.getWikiPageByUid(currentPageUid); + + // Updating the wikiPage, setting a null user which indicated this + // change was made in author + wikiService.markWikiPageAsDeleted(wikiPage); + + // Send removed page notifications + if ((toolSessionID != null) && (user != null)) { + notifyWikiChange(toolSessionID, "notify.pageRemoved.subject", "notify.pageRemoved.body", user, request); + } + + // return to the same page with information about being removed displayed + return this.returnToWiki(wikiForm, request, currentPageUid); + + } + + /** + * Restore a page previously marked as removed. + */ + @RequestMapping("/restorePage") + public String restorePage(@ModelAttribute WikiPageForm wikiForm, HttpServletRequest request) throws Exception { + // The page to be restored + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Get the session information for notifications + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + WikiUser user = getCurrentUser(toolSessionID); + + WikiPage wikiPage = wikiService.getWikiPageByUid(currentPageUid); + + // Updating the wikiPage + wikiService.restoreWikiPage(wikiPage); + + // Send removed page notifications + if ((toolSessionID != null) && (user != null)) { + notifyWikiChange(toolSessionID, "notify.pageRestored.subject", "notify.pageRestored.body", user, request); + } + + // return to the same page + return this.returnToWiki(wikiForm, request, currentPageUid); + + } + + /** + * Toggles whether a learner wants to receive notifications for wiki changes + */ + @RequestMapping("/toggleLearnerSubsciption") + public String toggleLearnerSubsciption(@ModelAttribute WikiPageForm wikiForm, HttpServletRequest request) throws Exception { + + Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID, true); + Long currentPageUid = WebUtil.readLongParam(request, WikiConstants.ATTR_CURRENT_WIKI); + + // Get the current user + HttpSession ss = SessionManager.getSession(); + UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); + + IEventNotificationService notificationService = wikiService.getEventNotificationService(); + notificationService.createEvent(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, null, null, false); + + // Get whether the user is subscribed + boolean subscribed = notificationService.isSubscribed(WikiConstants.TOOL_SIGNATURE, + WikiConstants.EVENT_NOTIFY_LEARNERS, toolSessionID, user.getUserID().longValue()); + + if (subscribed) { + // unsubscribe the learner to the event + notificationService.unsubscribe(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, user.getUserID()); + } else { + // subscribe the learner to the event + notificationService.subscribe(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, user.getUserID(), IEventNotificationService.DELIVERY_METHOD_MAIL); + } + + // return to the wiki page + return returnToWiki(wikiForm, request, currentPageUid); + + } + + private void notifyWikiChange(Long toolSessionID, String subjectLangKey, String bodyLangKey, WikiUser wikiUser, + HttpServletRequest request) throws Exception { + + + WikiSession wikiSession = wikiService.getSessionBySessionId(toolSessionID); + + IEventNotificationService notificationService = wikiService.getEventNotificationService(); + + String subject = wikiService.getLocalisedMessage(subjectLangKey, new Object[] { wikiSession.getSessionName() }); + String fullName = wikiUser.getFirstName() + " " + wikiUser.getLastName(); + + // Notify all the monitors + if (wikiSession.getWiki().isNotifyUpdates()) { + boolean isHtmlFormat = false; + + List monitors = wikiService.getMonitorsByToolSessionId(toolSessionID); + for (User monitor : monitors) { + Integer monitorUserId = monitor.getUserId(); + String contentFolderId = wikiService.getLearnerContentFolder(toolSessionID, monitorUserId.longValue()); + + String relativePath = "/tool/" + WikiConstants.TOOL_SIGNATURE + + "/monitoring.do?dispatch=showWiki&toolSessionID=" + toolSessionID.toString() + + "&contentFolderID=" + contentFolderId; + + String hash = relativePath + "," + toolSessionID.toString() + ",t"; + hash = new String(Base64.encodeBase64(hash.getBytes())); + + String link = Configuration.get(ConfigurationKeys.SERVER_URL) + "r.do?" + "h=" + hash; + + String body = wikiService.getLocalisedMessage(bodyLangKey, + new Object[] { fullName, wikiSession.getSessionName(), link }); + + notificationService.sendMessage(null, monitorUserId, IEventNotificationService.DELIVERY_METHOD_MAIL, + subject, body, isHtmlFormat); + } + + } + + // trigger the event if exists for all the learners who are subscribed + if (notificationService.eventExists(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID)) { + + String relativePath = "/tool/" + WikiConstants.TOOL_SIGNATURE + "/learning.do?mode=learner&toolSessionID=" + + toolSessionID.toString(); + + String hash = relativePath + "," + toolSessionID.toString() + ",l"; + hash = new String(Base64.encodeBase64(hash.getBytes())); + + String link = Configuration.get(ConfigurationKeys.SERVER_URL) + "r.do?" + "h=" + hash; + + String body = wikiService.getLocalisedMessage(bodyLangKey, + new Object[] { fullName, wikiSession.getSessionName(), link }); + + notificationService.trigger(WikiConstants.TOOL_SIGNATURE, WikiConstants.EVENT_NOTIFY_LEARNERS, + toolSessionID, subject, body); + } + } + + /** + * Replaces codeword back to "javascript", so the content works correctly after displaying. + */ + private void revertJavascriptTokenReplacement(WikiPageForm form) { + String encodedWikiBody = form.getNewPageWikiBody(); + if (encodedWikiBody != null) { + form.setNewPageWikiBody( + encodedWikiBody.replace(WikiConstants.JAVASCRIPT_REPLACE_TOKEN, WikiConstants.JAVASCRIPT_TOKEN)); + } + + encodedWikiBody = form.getWikiBody(); + if (encodedWikiBody != null) { + form.setWikiBody( + encodedWikiBody.replace(WikiConstants.JAVASCRIPT_REPLACE_TOKEN, WikiConstants.JAVASCRIPT_TOKEN)); + } + } +} Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/AuthoringForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r82c8ee6bc80d47736337c5b07ccc686c5ea3ba32 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -32,7 +32,12 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.web.util.SessionMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; /** * @@ -41,6 +46,10 @@ private static final long serialVersionUID = 353256767734345767L; + @Autowired + @Qualifier("wikiMessageService") + private MessageService messageService; + // Properties String offlineInstruction; @@ -85,12 +94,12 @@ SessionMap sessionMap; - @Override - public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { - ActionErrors ac = new ActionErrors(); - ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error")); + public MultiValueMap validate(HttpServletRequest arg1) { + MultiValueMap errorMap = new LinkedMultiValueMap<>(); - return ac; + errorMap.add("GLOBAL", messageService.getMessage("this is an error")); + + return errorMap; } public String getSessionMapID() { Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/LearningForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r82c8ee6bc80d47736337c5b07ccc686c5ea3ba32 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/LearningForm.java (.../LearningForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/LearningForm.java (.../LearningForm.java) (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -37,7 +37,6 @@ String title; String instructions; - String dispatch; Long toolSessionID; String mode; @@ -51,14 +50,6 @@ this.mode = mode; } - public String getDispatch() { - return dispatch; - } - - public void setDispatch(String dispatch) { - this.dispatch = dispatch; - } - public Long getToolSessionID() { return toolSessionID; } Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/MonitoringForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r82c8ee6bc80d47736337c5b07ccc686c5ea3ba32 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/MonitoringForm.java (.../MonitoringForm.java) (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -32,7 +32,6 @@ private static final long serialVersionUID = 9096908688391850595L; - String dispatch; boolean teacherVisible; Long toolSessionID; String contentFolderID; @@ -59,14 +58,6 @@ this.messageUID = messageUID; } - public String getDispatch() { - return dispatch; - } - - public void setDispatch(String dispatch) { - this.dispatch = dispatch; - } - public Long getToolSessionID() { return toolSessionID; } Index: lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/WikiPageForm.java =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r82c8ee6bc80d47736337c5b07ccc686c5ea3ba32 --- lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/WikiPageForm.java (.../WikiPageForm.java) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_wiki/src/java/org/lamsfoundation/lams/tool/wiki/web/forms/WikiPageForm.java (.../WikiPageForm.java) (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -21,17 +21,15 @@ * **************************************************************** */ - - package org.lamsfoundation.lams.tool.wiki.web.forms; import javax.servlet.http.HttpServletRequest; -import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionForm; -import org.apache.struts.action.ActionMapping; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.action.ActionMessages; +import org.lamsfoundation.lams.util.MessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; /** * This is a parent class for all wiki forms, it contains all the neccessary @@ -41,8 +39,12 @@ * * */ -public class WikiPageForm extends ActionForm { +public class WikiPageForm { + @Autowired + @Qualifier("wikiMessageService") + private MessageService messageService; + private static final long serialVersionUID = 234235265633376356L; String title; @@ -134,11 +136,11 @@ this.newPageIsEditable = newPageIsEditable; } - @Override - public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { - ActionErrors ac = new ActionErrors(); - ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error")); + public MultiValueMap validate(HttpServletRequest arg1) { + MultiValueMap errorMap = new LinkedMultiValueMap<>(); - return ac; + errorMap.add("GLOBAL", messageService.getMessage("this is an error")); + + return errorMap; } } Index: lams_tool_wiki/web/pages/monitoring/daterestriction.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r82c8ee6bc80d47736337c5b07ccc686c5ea3ba32 --- lams_tool_wiki/web/pages/monitoring/daterestriction.jsp (.../daterestriction.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_wiki/web/pages/monitoring/daterestriction.jsp (.../daterestriction.jsp) (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -10,9 +10,9 @@ - + - + @@ -21,9 +21,9 @@ - + - + \ No newline at end of file Index: lams_tool_wiki/web/pages/monitoring/editActivity.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r82c8ee6bc80d47736337c5b07ccc686c5ea3ba32 --- lams_tool_wiki/web/pages/monitoring/editActivity.jsp (.../editActivity.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_wiki/web/pages/monitoring/editActivity.jsp (.../editActivity.jsp) (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -29,13 +29,13 @@ - + - + - + Index: lams_tool_wiki/web/pages/monitoring/monitoring.jsp =================================================================== diff -u -r7475d08afc280b5e2e5ddf04e8bf35e3166aaf80 -r82c8ee6bc80d47736337c5b07ccc686c5ea3ba32 --- lams_tool_wiki/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 7475d08afc280b5e2e5ddf04e8bf35e3166aaf80) +++ lams_tool_wiki/web/pages/monitoring/monitoring.jsp (.../monitoring.jsp) (revision 82c8ee6bc80d47736337c5b07ccc686c5ea3ba32) @@ -1,27 +1,54 @@ + + <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.wiki.util.WikiConstants"%> - - - - - - - - - - + + + + + - - - - - - - + + + -