toolContentID
will be passed in. This
@@ -82,10 +96,6 @@
// Extract toolContentID from parameters.
Long toolContentID = new Long(WebUtil.readLongParam(request,
AttributeNames.PARAM_TOOL_CONTENT_ID));
- if (logger.isDebugEnabled()) {
- logger.debug("entering method unspecified: toolContentID = "
- + toolContentID);
- }
// set up chatService
if (chatService == null) {
@@ -104,106 +114,72 @@
// check if content in use is set
if (chat.getContentInUse()) {
- // Cannot edit while content is in use.
- request.setAttribute(ChatConstants.ATTR_MESSAGE, getResources(request).getMessage(
- "error.content.locked"));
+ // Cannot edit, send to message page.
+ request.setAttribute(ChatConstants.ATTR_MESSAGE, getResources(
+ request).getMessage("error.content.locked"));
return mapping.findForward("message_page");
}
- // set the defineLater flag so that learners cannot use content while we
- // are editing.
- // This flag is released when updateContent is called.
+ // Set the defineLater flag so that learners cannot use content while we
+ // are editing. This flag is released when updateContent is called.
chat.setDefineLater(true);
chatService.saveOrUpdateChat(chat);
- // set the access mode.
- ToolAccessMode mode = getAccessMode(request);
- request.setAttribute(AttributeNames.ATTR_MODE, mode.toString());
+ // Set up sessionMap
+ SessionMap map = new SessionMap();
+ initSessionMap(map, request);
+ updateSessionMap(map, chat);
- // create a new authoringSessionBean and add to session
- AuthoringSessionBean authSession = new AuthoringSessionBean();
- String id = ChatConstants.AUTH_SESSION_ID
- + createAuthSessionId(request.getSession());
- authSession.setAuthSessionId(id);
- authSession.setMode(mode);
- request.getSession().setAttribute(id, authSession);
-
- // set up the form.
+ // Set up the authForm.
AuthoringForm authForm = (AuthoringForm) form;
+ updateAuthForm(authForm, chat);
- // populating the AuthoringForm using Chat content
- populateAuthForm(authForm, chat);
- resetAuthSession(authSession, chat);
+ // add the sessionMapID to form
+ authForm.setSessionMapID(map.getSessionID());
- authForm.setAuthSession(authSession);
- authForm.setAuthSessionId(authSession.getAuthSessionId());
+ // add the sessionMap to HTTPSession.
+ request.getSession().setAttribute(map.getSessionID(), map);
+ // add the sessionMap to the HttpServletRequest
+ // TODO workaround until we can figure out how to get request
+ // attributes using dynamic attributes in jsps.
+ request.setAttribute(ChatConstants.ATTR_SESSION_MAP, map);
+
return mapping.findForward("success");
}
- private synchronized Long createAuthSessionId(HttpSession httpSession) {
- Long authSessionId = (Long) httpSession
- .getAttribute(ChatConstants.AUTH_SESSION_ID_COUNTER);
- if (authSessionId == null) {
- authSessionId = 1L;
- httpSession.setAttribute(ChatConstants.AUTH_SESSION_ID_COUNTER,
- authSessionId);
- } else {
- authSessionId++;
- }
- return authSessionId;
- }
-
public ActionForward updateContent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
-
- setAccessMode(request, form);
-
// TODO need error checking.
+
+ // get authForm and session map.
AuthoringForm authForm = (AuthoringForm) form;
+ SessionMap map = getSessionMap(request, authForm);
- // retrieving authoring session bean
- AuthoringSessionBean authSession = (AuthoringSessionBean) request
- .getSession().getAttribute(authForm.getAuthSessionId());
-
- // retrieve the content.
- if (chatService == null) {
- chatService = ChatServiceProxy.getChatService(this.getServlet()
- .getServletContext());
- }
+ // get chat content.
Chat chat = chatService.getChatByContentId(authForm.getToolContentID());
- // copy form inputs to content
- populateChat(chat, authForm);
+ // update chat content using form inputs.
+ updateChat(chat, authForm);
- // adding unsaved uploaded files.
+ // remove attachments marked for deletion.
Set attachments = chat.getChatAttachments();
if (attachments == null) {
attachments = new HashSet();
}
- attachments.addAll(authSession.getUnsavedOnlineFilesList());
- attachments.addAll(authSession.getUnsavedOfflineFilesList());
- // Removing attachments marked for deletion.
- List
- |
@@ -25,7 +24,7 @@
- |
- |
@@ -115,7 +112,7 @@