Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java,v diff -u -r1.27 -r1.28 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java 2 Feb 2009 03:38:28 -0000 1.27 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/persistence/MessageDao.java 24 Mar 2010 21:32:23 -0000 1.28 @@ -41,7 +41,7 @@ + " where is_authored = true and forum_uid=? order by create_date"; private static final String SQL_QUERY_FIND_CHILDREN = "from " + Message.class.getName() - + " where parent=?"; + + " where parent_uid=?"; private static final String SQL_QUERY_BY_USER_SESSION = "from " + Message.class.getName() + " m " + " where m.createdBy.uid = ? and m.toolSession.sessionId=?"; Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java,v diff -u -r1.73 -r1.74 --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java 23 Mar 2010 15:30:01 -0000 1.73 +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java 24 Mar 2010 21:32:22 -0000 1.74 @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; @@ -35,7 +36,6 @@ import java.util.List; import java.util.Set; import java.util.SortedSet; -import java.util.TreeMap; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -68,7 +68,6 @@ import org.lamsfoundation.lams.tool.forum.persistence.Message; import org.lamsfoundation.lams.tool.forum.persistence.PersistenceException; import org.lamsfoundation.lams.tool.forum.service.IForumService; -import org.lamsfoundation.lams.tool.forum.util.DateComparator; import org.lamsfoundation.lams.tool.forum.util.ForumConstants; import org.lamsfoundation.lams.tool.forum.util.ForumWebUtils; import org.lamsfoundation.lams.tool.forum.util.MessageComparator; @@ -95,7 +94,8 @@ @Override public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws IOException, ServletException, PersistenceException { + HttpServletResponse response) throws IOException, ServletException, PersistenceException, + IllegalAccessException, NoSuchMethodException, InvocationTargetException { String param = mapping.getParameter(); // -----------------------Forum Author function --------------------------- @@ -295,9 +295,12 @@ * @param request * @param response * @return + * @throws NoSuchMethodException + * @throws InvocationTargetException + * @throws IllegalAccessException */ public ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) { + HttpServletResponse response) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { ToolAccessMode mode = getAccessMode(request); ForumForm forumForm = (ForumForm) form; @@ -316,7 +319,7 @@ Forum forum = forumForm.getForum(); // get back tool content ID forum.setContentId(forumForm.getToolContentID()); - try { + forumService = getForumManager(); // *******************************Handle user******************* @@ -392,17 +395,16 @@ // copy back forumPO.setAttachments(attPOSet); forum = forumService.updateForum(forumPO); - - // ********************************Handle topic******************* + // delete message attachment List topicDeleteAttachmentList = getTopicDeletedAttachmentList(sessionMap); iter = topicDeleteAttachmentList.iterator(); while (iter.hasNext()) { Attachment delAtt = (Attachment) iter.next(); iter.remove(); - } + } - // Handle message + // ********************************Handle topic******************* Set topics = getTopics(sessionMap); iter = topics.iterator(); while (iter.hasNext()) { @@ -424,29 +426,27 @@ forumService.deleteTopic(dto.getMessage().getUid()); } } + + // ********************************Handle conditions (also delete conditions that don't contain any topics)**** + Set conditionSet = new TreeSet(new TextSearchConditionComparator()); + Set existingConditionSet = getForumConditionSet(sessionMap); + conditionSet.addAll(existingConditionSet); + forum.setConditions(conditionSet); + + List delConditions = getDeletedForumConditionList(sessionMap); + iter = delConditions.iterator(); + while (iter.hasNext()) { + ForumCondition condition = (ForumCondition) iter.next(); + iter.remove(); + forumService.deleteCondition(condition); + } - Set conditionSet = new TreeSet(new TextSearchConditionComparator()); - Set existingConditionSet = getForumConditionSet(sessionMap); - conditionSet.addAll(existingConditionSet); - forum.setConditions(conditionSet); + forum = forumService.updateForum(forum); - forum = forumService.updateForum(forum); + // initialize attachmentList again + attachmentList = getAttachmentList(sessionMap); + attachmentList.addAll(forum.getAttachments()); - List delConditions = getDeletedForumConditionList(sessionMap); - iter = delConditions.iterator(); - while (iter.hasNext()) { - ForumCondition condition = (ForumCondition) iter.next(); - iter.remove(); - forumService.deleteCondition(condition); - } - - // initialize attachmentList again - attachmentList = getAttachmentList(sessionMap); - attachmentList.addAll(forum.getAttachments()); - } catch (Exception e) { - AuthoringAction.log.error(e); - } - request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); if (mode.isAuthor()) { return mapping.findForward("author"); @@ -718,12 +718,12 @@ if (topicIdx != -1) { Set topics = getTopics(sessionMap); List rList = new ArrayList(topics); - Object obj = rList.remove(topicIdx); + MessageDTO item = rList.remove(topicIdx); topics.clear(); topics.addAll(rList); // add to delList List delList = getDeletedTopicList(sessionMap); - delList.add(obj); + delList.add(item); SortedSet list = getForumConditionSet(sessionMap); Iterator conditionIter = list.iterator(); @@ -732,7 +732,7 @@ ForumCondition condition = conditionIter.next(); Iterator topicIter = condition.getTopics().iterator(); while (topicIter.hasNext()) { - if (topicIter.next() == obj) { + if (topicIter.next() == item.getMessage()) { topicIter.remove(); } }