updateTopic
method. So topic can keep this attachment if user choose "Cancel" edit
+ * topic.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+
+ //only reset not attachment flag.
+ MessageDTO dto = new MessageDTO();
+ dto.setHasAttachment(false);
+ request.setAttribute(ForumConstants.AUTHORING_TOPIC, dto);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(WebUtil.readStrParam(request, ForumConstants.ATTR_SESSION_MAP_ID));
+ request.setAttribute(ForumConstants.ATTR_ALLOW_UPLOAD, sessionMap.get(ForumConstants.ATTR_ALLOW_UPLOAD));
+
+ return mapping.findForward("success");
+ }
/**
* Update a topic.
@@ -515,15 +518,15 @@
public ActionForward updateTopic(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws PersistenceException {
- // get value from HttpSession
- Long topicId = (Long) request.getSession().getAttribute("topicId");
-
- forumService = getForumManager();
+ forumService = getForumManager();
+
MessageForm messageForm = (MessageForm) form;
- Message message = messageForm.getMessage();
+ SessionMap sessionMap = getSessionMap(request, messageForm);
+ Long topicId = (Long) sessionMap.get(ForumConstants.ATTR_TOPIC_ID);
+ Message message = messageForm.getMessage();
- boolean makeAuditEntry = ToolAccessMode.TEACHER.equals((ToolAccessMode) request.getSession().getAttribute(AttributeNames.ATTR_MODE));
+ boolean makeAuditEntry = ToolAccessMode.TEACHER.equals((ToolAccessMode)sessionMap.get(AttributeNames.ATTR_MODE));
String oldMessageString = null;
// get PO from database and sync with Form
@@ -534,7 +537,7 @@
messagePO.setSubject(message.getSubject());
messagePO.setBody(message.getBody());
messagePO.setUpdated(new Date());
- messagePO.setModifiedBy(getCurrentUser(request));
+ messagePO.setModifiedBy(getCurrentUser(request,(Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID)));
setAttachment(messageForm, messagePO);
if ( makeAuditEntry ) {
@@ -548,16 +551,17 @@
forumService.updateTopic(messagePO);
// echo back this topic thread into page
- forumService = getForumManager();
Long rootTopicId = forumService.getRootTopicId(topicId);
List msgDtoList = forumService.getTopicThread(rootTopicId);
- setAuthorMark(msgDtoList);
+ updateMesssageFlag(msgDtoList);
request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList);
-
+ request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,messageForm.getSessionMapID());
+
return mapping.findForward("success");
}
+
/**
* Sets the visibility of a message by updating the hide flag for a message
*
@@ -571,21 +575,20 @@
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
- Long msgId = new Long(WebUtil.readLongParam(request, "msgId"));
+ Long msgId = new Long(WebUtil.readLongParam(request,ForumConstants.ATTR_TOPIC_ID));
Boolean hideFlag = new Boolean(WebUtil.readBooleanParam(request, "hideFlag"));
forumService = getForumManager();
+ // TODO Skipping permissions for now, currently having issues with default learning designs not having an create_by field
+// Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
// check if the user has permission to hide posts.
- Long sessionId = (Long) request.getSession().getAttribute(
- AttributeNames.PARAM_TOOL_SESSION_ID);
- ForumToolSession toolSession = forumService
- .getSessionBySessionId(sessionId);
-
- Forum forum = toolSession.getForum();
- ForumUser currentUser = getCurrentUser(request);
- ForumUser forumCreatedBy = forum.getCreatedBy();
+// ForumToolSession toolSession = forumService
+// .getSessionBySessionId(sessionId);
+//
+// Forum forum = toolSession.getForum();
+// ForumUser currentUser = getCurrentUser(request,sessionId);
+// ForumUser forumCreatedBy = forum.getCreatedBy();
- // TODO Skipping permissions for now, currently having issues with default learning designs not having an create_by field
// we should be looking at whether a user is a teacher and more specifically staff
// if (currentUser.getUserId().equals(forumCreatedBy.getUserId())) {
forumService.updateMessageHideFlag(msgId, hideFlag.booleanValue());
@@ -596,76 +599,26 @@
// echo back this topic thread into page
- forumService = getForumManager();
Long rootTopicId = forumService.getRootTopicId(msgId);
List msgDtoList = forumService.getTopicThread(rootTopicId);
- setAuthorMark(msgDtoList);
+ updateMesssageFlag(msgDtoList);
request.setAttribute(ForumConstants.AUTHORING_TOPIC_THREAD, msgDtoList);
-
- String title = getForumTitle(msgDtoList);
- request.setAttribute(ForumConstants.FORUM_TITLE,title);
- return mapping.findForward("success");
- }
+ request.setAttribute(ForumConstants.ATTR_SESSION_MAP_ID,WebUtil.readLongParam(request,ForumConstants.ATTR_SESSION_MAP_ID));
- /**
- * Only delete the attachemnt file for current topic.
- *
- * @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
- Long topicId = (Long) request.getSession().getAttribute("topicId");
- Long versionID = new Long(WebUtil.readLongParam(request, "versionID"));
- Long uuID = new Long(WebUtil.readLongParam(request, "uuid"));
- forumService = getForumManager();
- forumService.deleteFromRepository(uuID, versionID);
-
- boolean makeAuditEntry = ToolAccessMode.TEACHER.equals((ToolAccessMode) request.getSession().getAttribute(AttributeNames.ATTR_MODE));
- String oldMessageString = null;
-
- // get value from HttpSession
- Message messagePO = forumService.getMessage(topicId);
- if ( makeAuditEntry ) {
- oldMessageString = messagePO.toString();
- }
- messagePO.setUpdated(new Date());
- messagePO.setModifiedBy(getCurrentUser(request));
- Set atts = messagePO.getAttachments();
- if(atts != null)
- atts.clear();
-
- if ( makeAuditEntry ) {
- forumService.getAuditService().logChange(ForumConstants.TOOL_SIGNATURE,
- messagePO.getCreatedBy().getUserId(), messagePO.getCreatedBy().getLoginName(),
- oldMessageString, messagePO.toString());
- }
-
- // save message into database
- forumService.updateTopic(messagePO);
-
- String title = getForumTitle(messagePO);
- request.setAttribute(ForumConstants.FORUM_TITLE,title);
return mapping.findForward("success");
}
-
// ==========================================================================================
// Utility methods
// ==========================================================================================
/**
- * If this topic is created by current login user, then set Author mark
- * true.
+ * This method will set flag in message DTO:
+ *