Index: lams_tool_forum/conf/xdoclet/struts-actions.xml =================================================================== diff -u -r27d386f3472e12afab03d53dfde3ed9b1c9a44d3 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 27d386f3472e12afab03d53dfde3ed9b1c9a44d3) +++ lams_tool_forum/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -2,7 +2,7 @@ @@ -13,7 +13,7 @@ @@ -22,7 +22,7 @@ @@ -32,7 +32,7 @@ @@ -41,7 +41,7 @@ @@ -50,23 +50,27 @@ - + - + - + + @@ -78,13 +82,13 @@ input="/jsps/authoring/message/create.jsp" parameter="createTopic" scope="request"> - + - + + scope="request"> - + parameter="deleteAttachment"> + - - - - + scope="request"> - - - - + + @@ -192,7 +179,7 @@ name="messageForm" validate="false" parameter="editTopic" - scope="session"> + scope="request"> + scope="request"> + scope="request"> + scope="request"> Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java =================================================================== diff -u -r27d386f3472e12afab03d53dfde3ed9b1c9a44d3 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision 27d386f3472e12afab03d53dfde3ed9b1c9a44d3) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumConstants.java (.../ForumConstants.java) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -48,7 +48,6 @@ public static final String DEFAULT_TITLE = "Forum"; //TODO:hard code!!! need to read from config public static final String TOOL_URL_BASE = "/lams/tool/lafrum11/"; - public static final String SUCCESS_FLAG = "SUCCESS_FLAG"; public static final String FORUM_ID = "forum_id"; public static final int SESSION_STATUS_FINISHED = 1; @@ -95,7 +94,9 @@ public static final String ATTR_NO_MORE_POSTS = "noMorePosts"; + public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; + } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumWebUtils.java =================================================================== diff -u -rd9c7ddef141d19423b6ab2914d153c2cb748f187 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumWebUtils.java (.../ForumWebUtils.java) (revision d9c7ddef141d19423b6ab2914d153c2cb748f187) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/util/ForumWebUtils.java (.../ForumWebUtils.java) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -24,8 +24,13 @@ /* $$Id$$ */ package org.lamsfoundation.lams.tool.forum.util; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.lang.StringUtils; +import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.forum.persistence.Forum; import org.lamsfoundation.lams.tool.forum.persistence.ForumException; +import org.lamsfoundation.lams.web.util.AttributeNames; /** @@ -49,5 +54,23 @@ else // (content.isContentInUse()==true && content.isDefineLater() == false) return false; } + + /** + * Get ToolAccessMode from HttpRequest parameters. Default value is AUTHOR mode. + * @param request + * @return + */ + public static ToolAccessMode getAccessMode(HttpServletRequest request) { + ToolAccessMode mode = null; + String modeStr = request.getParameter(AttributeNames.ATTR_MODE); + if(StringUtils.equalsIgnoreCase(modeStr,ToolAccessMode.TEACHER.toString())) + mode = ToolAccessMode.TEACHER; + else if (StringUtils.equalsIgnoreCase(modeStr,ToolAccessMode.AUTHOR.toString())) + mode = ToolAccessMode.AUTHOR; + else if (StringUtils.equalsIgnoreCase(modeStr,ToolAccessMode.LEARNER.toString())) + mode = ToolAccessMode.LEARNER; + + return mode; + } } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java =================================================================== diff -u -r8538ea9651f478bd2973da6eda56176902fa92d7 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 8538ea9651f478bd2973da6eda56176902fa92d7) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -26,7 +26,6 @@ package org.lamsfoundation.lams.tool.forum.web.actions; import java.io.IOException; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; @@ -45,7 +44,6 @@ import org.apache.commons.lang.math.NumberUtils; import org.apache.log4j.Logger; import org.apache.struts.action.Action; -import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; @@ -72,6 +70,7 @@ import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -89,14 +88,14 @@ String param = mapping.getParameter(); //-----------------------Forum Author function --------------------------- if (param.equals("initPage")) { - request.getSession().setAttribute(AttributeNames.ATTR_MODE,ToolAccessMode.AUTHOR); + request.setAttribute(AttributeNames.ATTR_MODE,ToolAccessMode.AUTHOR); return initPage(mapping, form, request, response); } // ***************** Monitoring define later screen ******************** if (param.equals("defineLater")){ //update define later flag to true - request.getSession().setAttribute(AttributeNames.ATTR_MODE,ToolAccessMode.TEACHER); + request.setAttribute(AttributeNames.ATTR_MODE,ToolAccessMode.TEACHER); forumService = getForumManager(); Long contentId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); Forum forum = forumService.getForumByContentId(contentId); @@ -151,12 +150,6 @@ if (param.equals("deleteAttachment")) { return deleteAttachment(mapping, form, request, response); } - if (param.equals("refreshTopic")) { - return refreshTopic(mapping, form, request, response); - } - if (param.equals("finishTopic")) { - return finishTopic(mapping, form, request, response); - } return mapping.findForward("error"); } //****************************************************************************************************************** @@ -174,10 +167,14 @@ */ protected ActionForward initPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - - ToolAccessMode mode = (ToolAccessMode) request.getSession().getAttribute(AttributeNames.ATTR_MODE); + //initial Session Map + SessionMap sessionMap = new SessionMap(); + request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap); + Long contentId = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); ForumForm forumForm = (ForumForm)form; + forumForm.setSessionMapID(sessionMap.getSessionID()); + //get back the topic list and display them on page forumService = getForumManager(); @@ -203,7 +200,7 @@ topics = forumService.getAuthoredTopics(forum.getUid()); } //initialize attachmentList - List attachmentList = getAttachmentList(request); + List attachmentList = getAttachmentList(sessionMap); attachmentList.addAll(forum.getAttachments()); //tear down PO to normal object using clone() method @@ -217,7 +214,8 @@ //init it to avoid null exception in following handling if(topics == null) topics = new ArrayList(); - request.getSession().setAttribute(ForumConstants.AUTHORING_TOPICS_LIST, topics); + + sessionMap.put(ForumConstants.AUTHORING_TOPICS_LIST, topics); return mapping.findForward("success"); } /** @@ -242,6 +240,7 @@ ToolAccessMode mode = getAccessMode(request); ForumForm forumForm = (ForumForm)(form); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(forumForm.getSessionMapID()); //validation ActionMessages errors = validate(forumForm, mapping, request); if(!errors.isEmpty()){ @@ -293,8 +292,8 @@ Set attPOSet = forumPO.getAttachments(); if(attPOSet == null) attPOSet = new HashSet(); - List attachmentList = getAttachmentList(request); - List deleteAttachmentList = getDeletedAttachmentList(request); + List attachmentList = getAttachmentList(sessionMap); + List deleteAttachmentList = getDeletedAttachmentList(sessionMap); Iterator iter = attachmentList.iterator(); while(iter.hasNext()){ Attachment newAtt = (Attachment) iter.next(); @@ -330,7 +329,7 @@ //********************************Handle topic******************* //delete message attachment - List topicDeleteAttachmentList = getTopicDeletedAttachmentList(request); + List topicDeleteAttachmentList = getTopicDeletedAttachmentList(sessionMap); iter = topicDeleteAttachmentList.iterator(); while(iter.hasNext()){ Attachment delAtt = (Attachment) iter.next(); @@ -340,7 +339,7 @@ } //Handle message - List topics = getTopicList(request); + List topics = getTopicList(sessionMap); iter = topics.iterator(); while(iter.hasNext()){ MessageDTO dto = (MessageDTO) iter.next(); @@ -352,7 +351,7 @@ } } //delete them from database. - List delTopics = getDeletedTopicList(request); + List delTopics = getDeletedTopicList(sessionMap); iter = delTopics.iterator(); while(iter.hasNext()){ MessageDTO dto = (MessageDTO) iter.next(); @@ -362,7 +361,7 @@ } //initialize attachmentList again - attachmentList = getAttachmentList(request); + attachmentList = getAttachmentList(sessionMap); attachmentList.addAll(forum.getAttachments()); } catch (Exception e) { log.error(e); @@ -412,6 +411,7 @@ String type,HttpServletRequest request) { ForumForm forumForm = (ForumForm) form; + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(forumForm.getSessionMapID()); FormFile file; if(StringUtils.equals(IToolContentHandler.TYPE_OFFLINE,type)) @@ -424,8 +424,8 @@ Attachment att = forumService.uploadInstructionFile(file, type); //handle session value - List attachmentList = getAttachmentList(request); - List deleteAttachmentList = getDeletedAttachmentList(request); + List attachmentList = getAttachmentList(sessionMap); + List deleteAttachmentList = getDeletedAttachmentList(sessionMap); //first check exist attachment and delete old one (if exist) to deletedAttachmentList Iterator iter = attachmentList.iterator(); Attachment existAtt; @@ -442,21 +442,18 @@ attachmentList.add(att); //update Html FORM, this will echo back to web page for display - List list; - if(StringUtils.equals(IToolContentHandler.TYPE_OFFLINE,type)){ - list = forumForm.getOfflineFileList(); - if(list == null){ - list = new ArrayList(); - forumForm.setOfflineFileList(list); - } - }else{ - list = forumForm.getOnlineFileList(); - if(list == null){ - list = new ArrayList(); - forumForm.setOnlineFileList(list); - } + List onlineFileList = new ArrayList(); + List offlineFileList = new ArrayList(); + iter = attachmentList.iterator(); + while(iter.hasNext()){ + Attachment attFile = (Attachment) iter.next(); + if(StringUtils.equalsIgnoreCase(attFile.getFileType(),IToolContentHandler.TYPE_OFFLINE)) + offlineFileList.add(attFile); + else + onlineFileList.add(attFile); } - list.add(att); + forumForm.setOnlineFileList(onlineFileList); + forumForm.setOfflineFileList(offlineFileList); return mapping.findForward("success"); @@ -473,7 +470,7 @@ */ public ActionForward deleteOfflineFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - return deleteFile(request, response,form, IToolContentHandler.TYPE_OFFLINE); + return deleteFile(mapping, form,request, response, IToolContentHandler.TYPE_OFFLINE); } /** * Delete online instruction file from current Forum authoring page. @@ -485,7 +482,7 @@ */ public ActionForward deleteOnlineFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - return deleteFile(request, response,form, IToolContentHandler.TYPE_ONLINE); + return deleteFile(mapping, form,request, response, IToolContentHandler.TYPE_ONLINE); } /** @@ -495,91 +492,38 @@ * @param type * @return */ - private ActionForward deleteFile(HttpServletRequest request, HttpServletResponse response, ActionForm form, String type) { - Long contentID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID)); + private ActionForward deleteFile(ActionMapping mapping,ActionForm form,HttpServletRequest request, HttpServletResponse response, String type){ Long versionID = new Long(WebUtil.readLongParam(request,"versionID")); Long uuID = new Long(WebUtil.readLongParam(request,"uuID")); + //get sessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); //handle session value - List attachmentList = getAttachmentList(request); - List deleteAttachmentList = getDeletedAttachmentList(request); + List attachmentList = getAttachmentList(sessionMap); + List deleteAttachmentList = getDeletedAttachmentList(sessionMap); //first check exist attachment and delete old one (if exist) to deletedAttachmentList Iterator iter = attachmentList.iterator(); Attachment existAtt; + List leftAttachments = new ArrayList(); while(iter.hasNext()){ existAtt = (Attachment) iter.next(); if(existAtt.getFileUuid().equals(uuID) && existAtt.getFileVersionId().equals(versionID)){ //if there is same name attachment, delete old one deleteAttachmentList.add(existAtt); iter.remove(); - break; + }else if(StringUtils.equals(existAtt.getFileType(),type) ){ + leftAttachments.add(existAtt); } + } - - //handle web page display - List leftAttachments; + if(StringUtils.equals(IToolContentHandler.TYPE_OFFLINE,type)){ - leftAttachments = ((ForumForm)form).getOfflineFileList(); + request.setAttribute("offlineFileList",leftAttachments); }else{ - leftAttachments = ((ForumForm)form).getOnlineFileList(); + request.setAttribute("onlineFileList",leftAttachments); } - iter = leftAttachments.iterator(); - while(iter.hasNext()){ - Attachment att = (Attachment) iter.next(); - if(versionID.equals(att.getFileVersionId()) && uuID.equals(att.getFileUuid())){ - iter.remove(); - break; - } - } - StringBuffer sb = new StringBuffer(); - iter = leftAttachments.iterator(); - - boolean hasAtts = iter.hasNext(); - - if (hasAtts) { - sb.append("
    "); - } - while(iter.hasNext()){ - Attachment file = (Attachment) iter.next(); - sb.append("
  • ").append(file.getFileName()).append("\r\n"); - sb.append(" "); - sb.append(this.getResources(request).getMessage("label.view")); - sb.append("\r\n"); - sb.append(" "); - sb.append(this.getResources(request).getMessage("label.download")); - sb.append("\r\n"); - sb.append(""); - - if(StringUtils.equals(type,IToolContentHandler.TYPE_OFFLINE)) - sb.append(this.getResources(request).getMessage("label.authoring.offline.delete")); - else - sb.append(this.getResources(request).getMessage("label.authoring.online.delete")); - sb.append("
  • \r\n"); - } - if (hasAtts) { - sb.append("
      "); - } - try { - PrintWriter out = response.getWriter(); - out.print(sb.toString()); - out.flush(); - } catch (IOException e) { - log.error(e); - } - return null; + return mapping.findForward("success"); } //****************************************************************************************************************** @@ -597,6 +541,8 @@ */ private ActionForward newTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID ); + ((MessageForm)form).setSessionMapID(sessionMapID); return mapping.findForward("success"); } @@ -614,15 +560,17 @@ */ public ActionForward createTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, PersistenceException { + MessageForm messageForm = (MessageForm) form; + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(messageForm.getSessionMapID()); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); - List topics = getTopicList(request); + List topics = getTopicList(sessionMap); //get login user (author) HttpSession ss = SessionManager.getSession(); //get back login user DTO UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); //get message info from web page - MessageForm messageForm = (MessageForm) form; Message message = messageForm.getMessage(); //init some basic variables for first time create message.setIsAuthored(true); @@ -655,34 +603,7 @@ //save the new message into HttpSession topics.add(0,MessageDTO.getMessageDTO(message)); - //echo back to web page - request.setAttribute(ForumConstants.SUCCESS_FLAG,"CREATE_SUCCESS"); - return mapping.findForward("success"); - } - /** - * Delete a topic form current topic list. But database record will be deleted only when user save whole authoring - * page. - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws PersistenceException - */ - public ActionForward deleteTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws PersistenceException { - - List topics = getTopicList(request); - String topicIndex = (String) request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); - int topicIdx = NumberUtils.stringToInt(topicIndex,-1); - - if(topicIdx != -1){ - Object obj = topics.remove(topicIdx); - List delList = getDeletedTopicList(request); - delList.add(obj); - } - request.setAttribute(ForumConstants.SUCCESS_FLAG,"DELETE_SUCCESS"); return mapping.findForward("success"); } /** @@ -699,7 +620,12 @@ public ActionForward viewTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws PersistenceException { - List topics = getTopicList(request); + //get SessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID ); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, sessionMapID); + + List topics = getTopicList(sessionMap); String topicIndex = (String) request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); int topicIdx = NumberUtils.stringToInt(topicIndex,-1); @@ -719,6 +645,35 @@ return mapping.findForward("success"); } + /** + * Delete a topic form current topic list. But database record will be deleted only when user save whole authoring + * page. + * @param mapping + * @param form + * @param request + * @param response + * @return + * @throws PersistenceException + */ + public ActionForward deleteTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws PersistenceException { + //get SessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID ); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,sessionMapID); + List topics = getTopicList(sessionMap); + String topicIndex = (String) request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); + int topicIdx = NumberUtils.stringToInt(topicIndex,-1); + + if(topicIdx != -1){ + Object obj = topics.remove(topicIdx); + List delList = getDeletedTopicList(sessionMap); + delList.add(obj); + } + + return mapping.findForward("success"); + } + /** * Display a HTML FORM which contains subject, body and attachment information from a special topic. This page * is ready for user update this topic. @@ -733,8 +688,14 @@ public ActionForward editTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws PersistenceException { - MessageForm msgForm = (MessageForm)form; - List topics = getTopicList(request); +// get SessionMAP + String sessionMapID = WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID ); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + MessageForm msgForm = (MessageForm)form; + msgForm.setSessionMapID(sessionMapID); + + List topics = getTopicList(sessionMap); String topicIndex = (String) request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); int topicIdx = NumberUtils.stringToInt(topicIndex,-1); if(topicIdx != -1){ @@ -774,14 +735,17 @@ */ public ActionForward updateTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws PersistenceException { + MessageForm messageForm = (MessageForm) form; + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(messageForm.getSessionMapID()); + request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID, messageForm.getSessionMapID()); + //get value from HttpSession - List topics = getTopicList(request); + List topics = getTopicList(sessionMap); //get param from HttpServletRequest String topicIndex = (String) request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); int topicIdx = NumberUtils.stringToInt(topicIndex,-1); if(topicIdx != -1){ - MessageForm messageForm = (MessageForm) form; Message message = messageForm.getMessage(); MessageDTO newMsg = (MessageDTO) topics.get(topicIdx); @@ -801,87 +765,29 @@ attSet.add(att); newMsg.setHasAttachment(true); newMsg.getMessage().setAttachments(attSet); + }else if(!messageForm.isHasAttachment()){ + newMsg.setHasAttachment(false); + newMsg.getMessage().setAttachments(null); } } request.setAttribute(ForumConstants.AUTHORING_TOPICS_INDEX,topicIndex); - request.setAttribute(ForumConstants.SUCCESS_FLAG,"EDIT_SUCCESS"); return mapping.findForward("success"); } - /** - * Delete a topic's attachment file. This update will be submit to database only when user - * save whole authoring page. - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws PersistenceException - */ - public ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws PersistenceException { - -// get value from HttpSession - List topics = getTopicList(request); - //get param from HttpServletRequest - String topicIndex = (String) request.getParameter(ForumConstants.AUTHORING_TOPICS_INDEX); - - int topicIdx = NumberUtils.stringToInt(topicIndex,-1); - - if(topicIdx != -1){ - MessageDTO newMsg = (MessageDTO) topics.get(topicIdx); - if(newMsg.getMessage()== null) - newMsg.setMessage(new Message()); - //add delete topic attachment to HTTPSession - Set attSet = newMsg.getMessage().getAttachments(); - if(attSet != null){ - //only one attachment for topic - Attachment att = (Attachment) attSet.iterator().next(); - if(att != null){ - List topicDeletedAttachmentList = getTopicDeletedAttachmentList(request); - topicDeletedAttachmentList.add(att); - } - } - //set other infor about attachment - newMsg.getMessage().setUpdated(new Date()); - newMsg.setHasAttachment(false); - newMsg.getMessage().setAttachments(null); - } - - request.setAttribute(ForumConstants.SUCCESS_FLAG,"ATT_SUCCESS_FLAG"); - request.setAttribute(ForumConstants.AUTHORING_TOPICS_INDEX,topicIndex); + /** + * Remove message attachment. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { + request.setAttribute("itemAttachment", null); return mapping.findForward("success"); } - - public ActionForward refreshTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws PersistenceException { - return mapping.findForward("success"); - - } - - public ActionForward finishTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws PersistenceException { - List topics = getTopicList(request); - - ForumForm forumForm = (ForumForm)form; - Forum forum = forumForm.getForum(); - Set msgSet = new HashSet(); - Iterator iter = topics.iterator(); - while(iter.hasNext()){ - MessageDTO dto = (MessageDTO) iter.next(); - msgSet.add(dto.getMessage()); - } - forum.setMessages(msgSet); - - ToolAccessMode mode = (ToolAccessMode) request.getSession().getAttribute(AttributeNames.ATTR_MODE); - if(mode.isAuthor()) - return mapping.findForward("author"); - else - return mapping.findForward("monitor"); - - } - //****************************************************************************************************************** // Private method for internal functions //****************************************************************************************************************** @@ -896,36 +802,36 @@ * @param request * @return */ - private List getAttachmentList(HttpServletRequest request) { - return getListFromSession(request,ForumConstants.ATTACHMENT_LIST); + private List getAttachmentList(SessionMap sessionMap) { + return getListFromSession(sessionMap,ForumConstants.ATTACHMENT_LIST); } /** * @param request * @return */ - private List getDeletedAttachmentList(HttpServletRequest request) { - return getListFromSession(request,ForumConstants.DELETED_ATTACHMENT_LIST); + private List getDeletedAttachmentList(SessionMap sessionMap) { + return getListFromSession(sessionMap,ForumConstants.DELETED_ATTACHMENT_LIST); } /** * @param request * @return */ - private List getTopicList(HttpServletRequest request) { - return getListFromSession(request,ForumConstants.AUTHORING_TOPICS_LIST); + private List getTopicList(SessionMap sessionMap) { + return getListFromSession(sessionMap,ForumConstants.AUTHORING_TOPICS_LIST); } /** * @param request * @return */ - private List getTopicDeletedAttachmentList(HttpServletRequest request) { - return getListFromSession(request,ForumConstants.DELETED_ATTACHMENT_LIST); + private List getTopicDeletedAttachmentList(SessionMap sessionMap) { + return getListFromSession(sessionMap,ForumConstants.DELETED_ATTACHMENT_LIST); } /** * @param request * @return */ - private List getDeletedTopicList(HttpServletRequest request) { - return getListFromSession(request,ForumConstants.DELETED_AUTHORING_TOPICS_LIST); + private List getDeletedTopicList(SessionMap sessionMap) { + return getListFromSession(sessionMap,ForumConstants.DELETED_AUTHORING_TOPICS_LIST); } /** * Get java.util.List from HttpSession by given name. @@ -934,14 +840,15 @@ * @param name * @return */ - private List getListFromSession(HttpServletRequest request,String name) { - List list = (List) request.getSession().getAttribute(name); + private List getListFromSession(SessionMap sessionMap,String name) { + List list = (List) sessionMap.get(name); if(list == null){ list = new ArrayList(); - request.getSession().setAttribute(name,list); + sessionMap.put(name,list); } return list; } + /** * Get ToolAccessMode from HttpRequest parameters. Default value is AUTHOR mode. * @param request @@ -964,14 +871,15 @@ public ActionMessages validate( ForumForm form,ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { ActionMessages errors = new ActionMessages(); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(form.getSessionMapID()); ActionMessage ae; try { if (StringUtils.isBlank(form.getForum().getTitle())) { ActionMessage error = new ActionMessage("error.title.empty"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); } if(!form.getForum().isAllowNewTopic()){ - List topics = getTopicList(request); + List topics = getTopicList(sessionMap); if(topics.size() == 0){ ActionMessage error = new ActionMessage("error.must.have.topic"); errors.add(ActionMessages.GLOBAL_MESSAGE, error); Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ClearSessionAction.java =================================================================== diff -u -r6f0b2f51a5dd4135371017fd19a2292c35220689 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ClearSessionAction.java (.../ClearSessionAction.java) (revision 6f0b2f51a5dd4135371017fd19a2292c35220689) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/ClearSessionAction.java (.../ClearSessionAction.java) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -28,8 +28,6 @@ import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction; import org.lamsfoundation.lams.tool.ToolAccessMode; -import org.lamsfoundation.lams.tool.forum.util.ForumConstants; -import org.lamsfoundation.lams.web.util.AttributeNames; /** * This class give a chance to clear HttpSession when user save/close authoring page. @@ -42,12 +40,7 @@ @Override public void clearSession(String customiseSessionID,HttpSession session, ToolAccessMode mode) { if(mode.isAuthor()){ - session.removeAttribute(AttributeNames.ATTR_MODE); - session.removeAttribute(ForumConstants.AUTHORING_TOPICS_LIST); - session.removeAttribute(ForumConstants.ATTACHMENT_LIST); - session.removeAttribute(ForumConstants.DELETED_ATTACHMENT_LIST); - session.removeAttribute(ForumConstants.DELETED_ATTACHMENT_LIST); - session.removeAttribute(ForumConstants.DELETED_AUTHORING_TOPICS_LIST); + session.removeAttribute(customiseSessionID); } } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java =================================================================== diff -u -rb56d90d0894b861844b15ebdb81a6587e7933e63 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java (.../ForumForm.java) (revision b56d90d0894b861844b15ebdb81a6587e7933e63) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/ForumForm.java (.../ForumForm.java) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -62,6 +62,8 @@ //Forum fields private Long toolContentID; private String currentTab; + private String sessionMapID; + private FormFile offlineFile; private FormFile onlineFile; private List onlineFileList; @@ -168,5 +170,11 @@ public void setOnlineFileList(List onlineFileList) { this.onlineFileList = onlineFileList; } + public String getSessionMapID() { + return sessionMapID; + } + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; + } } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java =================================================================== diff -u -r427a3b63491fb2f3206a785705ac247af49e1360 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java (.../MessageForm.java) (revision 427a3b63491fb2f3206a785705ac247af49e1360) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java (.../MessageForm.java) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -32,6 +32,7 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.upload.FormFile; import org.apache.struts.validator.ValidatorForm; +import org.lamsfoundation.lams.tool.forum.persistence.Attachment; import org.lamsfoundation.lams.tool.forum.persistence.Message; /** @@ -48,10 +49,12 @@ private static Logger logger = Logger.getLogger(ForumForm.class.getName()); protected Message message; + protected String sessionMapID; protected Long forumId; protected Long parentId; protected Long topicId; + private boolean hasAttachment; //attachment file name private String attachmentName; //Message attachment file @@ -85,6 +88,16 @@ //-------------------------get/set methods---------------- public void setMessage(Message message) { this.message = message; + if(message != null){ + if(message.getAttachments() != null + && message.getAttachments().size() > 0){ + hasAttachment = true; + attachmentName = ((Attachment)message.getAttachments().iterator().next()).getFileName(); + }else{ + hasAttachment = false; + attachmentName = null; + } + } } public Message getMessage() { @@ -131,4 +144,16 @@ public void setAttachmentFile(FormFile attachmentFile) { this.attachmentFile = attachmentFile; } + public String getSessionMapID() { + return sessionMapID; + } + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; + } + public boolean isHasAttachment() { + return hasAttachment; + } + public void setHasAttachment(boolean hasAttachment) { + this.hasAttachment = hasAttachment; + } } Index: lams_tool_forum/web/WEB-INF/struts-config.xml =================================================================== diff -u -r27d386f3472e12afab03d53dfde3ed9b1c9a44d3 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 27d386f3472e12afab03d53dfde3ed9b1c9a44d3) +++ lams_tool_forum/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -52,7 +52,7 @@ @@ -62,15 +62,15 @@ @@ -80,37 +80,41 @@ - + - + + @@ -121,12 +125,12 @@ input="/jsps/authoring/message/create.jsp" parameter="createTopic" scope="request"> - + - + + scope="request"> - + parameter="deleteAttachment"> + - - - + scope="request"> - - - - + + scope="request"> + scope="request"> + scope="request"> + scope="request"> <%@ attribute name="cancelConfirmMsgKey" required="false" rtexprvalue="true" %> <%@ attribute name="defineLater" required="false" rtexprvalue="true" %> +<%@ attribute name="customiseSessionID" required="false" rtexprvalue="true" %> <%-- Default value for message key --%> @@ -63,14 +64,14 @@ Index: lams_tool_forum/web/common/header.jsp =================================================================== diff -u -rc277bb1c30c1283b5f66c6f651855c51a5f87bc5 -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/web/common/header.jsp (.../header.jsp) (revision c277bb1c30c1283b5f66c6f651855c51a5f87bc5) +++ lams_tool_forum/web/common/header.jsp (.../header.jsp) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -35,6 +35,5 @@ - <%@ include file="/common/fckeditorheader.jsp"%> Index: lams_tool_forum/web/error.jsp =================================================================== diff -u -r88acb04987abd12bc87754fbbe1f835dcd99a5cc -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/web/error.jsp (.../error.jsp) (revision 88acb04987abd12bc87754fbbe1f835dcd99a5cc) +++ lams_tool_forum/web/error.jsp (.../error.jsp) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -54,8 +54,8 @@
      - - + +
      + + + + - + + + + + + - - - - - - - -
      -
      -
        - -
      • - - - - -   - - - -   - - - - - - -
      • -
        -
      +
      + +
      + +
      + <%@ include file="parts/onlinefilelist.jsp" %>
      - -
      - - - - - - - -
      - -
      - - - - - - - + + + + + + + + - - - - - - - - -
      - -
      + : + -
      -
        - -
      • - - - - - - - - - - - - - - - - - - - -
      • -
        -
      + + + + + + +
      + +
      + +
      + <%@ include file="parts/offlinefilelist.jsp" %>
      - -
      - - - - - - - -
      + + + : + + + + + + + + +

       

      + + + + \ No newline at end of file Index: lams_tool_forum/web/jsps/authoring/message/create.jsp =================================================================== diff -u -raf3676b09dd96148e87da09c1a2c26c2d101da5b -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/web/jsps/authoring/message/create.jsp (.../create.jsp) (revision af3676b09dd96148e87da09c1a2c26c2d101da5b) +++ lams_tool_forum/web/jsps/authoring/message/create.jsp (.../create.jsp) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -2,37 +2,17 @@ "http://www.w3.org/TR/html4/strict.dtd"> <%@ include file="/common/taglibs.jsp"%> + <%@ include file="/common/header.jsp"%> - - - <%@ include file="/common/messages.jsp"%> +
      *
      @@ -43,7 +23,6 @@
      *
      - <%@ include file="/common/header.jsp"%> - + + + + <%@ include file="/common/messages.jsp"%> "> + Index: lams_tool_forum/web/jsps/authoring/message/topiclist.jsp =================================================================== diff -u -r0c3d585b0228e4b6913ca6f6a547e76f367c6d8b -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/web/jsps/authoring/message/topiclist.jsp (.../topiclist.jsp) (revision 0c3d585b0228e4b6913ca6f6a547e76f367c6d8b) +++ lams_tool_forum/web/jsps/authoring/message/topiclist.jsp (.../topiclist.jsp) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -1,16 +1,17 @@ -<%@ include file="/includes/taglibs.jsp" %> +<%@ include file="/common/taglibs.jsp" %>
      @@ -41,7 +40,7 @@ imageUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Image" linkUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=File" flashUploadURL="/FCKeditor/editor/filemanager/upload/simpleuploader?Type=Flash" - toolbarSet="Default-Learner" defaultLanguage="${language}" autoDetectLanguage="false"> + toolbarSet="Default-Learner" defaultLanguage="${language}" autoDetectLanguage="false"> @@ -51,23 +50,10 @@
      - - - - - - - - - -    - - - - - - -
      + +
      + <%@ include file="/jsps/authoring/parts/msgattachment.jsp"%> +
      - + +
      - + @@ -32,3 +33,12 @@
      +<%-- This script will works when a new resoruce item submit in order to refresh "Resource List" panel. --%> + \ No newline at end of file Index: lams_tool_forum/web/jsps/authoring/message/view.jsp =================================================================== diff -u -r0c3d585b0228e4b6913ca6f6a547e76f367c6d8b -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_forum/web/jsps/authoring/message/view.jsp (.../view.jsp) (revision 0c3d585b0228e4b6913ca6f6a547e76f367c6d8b) +++ lams_tool_forum/web/jsps/authoring/message/view.jsp (.../view.jsp) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -6,35 +6,21 @@ <%@ include file="/common/header.jsp"%> - - + --> + - @@ -73,13 +59,13 @@ - + - + Index: lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp =================================================================== diff -u --- lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp (revision 0) +++ lams_tool_forum/web/jsps/authoring/parts/msgattachment.jsp (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -0,0 +1,24 @@ +<%@ include file="/common/taglibs.jsp" %> + + + + +
      + + + + +
      + + + + + + + +
      + + + + + Index: lams_tool_forum/web/jsps/authoring/parts/offlinefilelist.jsp =================================================================== diff -u --- lams_tool_forum/web/jsps/authoring/parts/offlinefilelist.jsp (revision 0) +++ lams_tool_forum/web/jsps/authoring/parts/offlinefilelist.jsp (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -0,0 +1,31 @@ +<%@ include file="/common/taglibs.jsp" %> + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + +
      \ No newline at end of file Index: lams_tool_forum/web/jsps/authoring/parts/onlinefilelist.jsp =================================================================== diff -u --- lams_tool_forum/web/jsps/authoring/parts/onlinefilelist.jsp (revision 0) +++ lams_tool_forum/web/jsps/authoring/parts/onlinefilelist.jsp (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -0,0 +1,31 @@ +<%@ include file="/common/taglibs.jsp" %> + + + + + + + + + +
      + + + + + + + + + + + + + + + + + + + +
      \ No newline at end of file Index: lams_tool_larsrc/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r0f16af06eaa594f2115829f31a5ddc1f8a59721d -red2ba1bbc68b8f3ed22c009b0942ae6967b290a2 --- lams_tool_larsrc/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 0f16af06eaa594f2115829f31a5ddc1f8a59721d) +++ lams_tool_larsrc/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision ed2ba1bbc68b8f3ed22c009b0942ae6967b290a2) @@ -45,6 +45,7 @@ <%@ attribute name="saveButtonLabelKey" required="false" rtexprvalue="true" %> <%@ attribute name="cancelConfirmMsgKey" required="false" rtexprvalue="true" %> <%@ attribute name="defineLater" required="false" rtexprvalue="true" %> +<%@ attribute name="customiseSessionID" required="false" rtexprvalue="true" %> <%-- Default value for message key --%> @@ -63,14 +64,14 @@