Index: lams_tool_forum/web/WEB-INF/classes/ApplicationResources.properties =================================================================== diff -u -rdb911c3802e8b764988d3e9cc741583085d73273 -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/classes/ApplicationResources.properties (.../ApplicationResources.properties) (revision db911c3802e8b764988d3e9cc741583085d73273) +++ lams_tool_forum/web/WEB-INF/classes/ApplicationResources.properties (.../ApplicationResources.properties) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -38,17 +38,16 @@ ##Message title.messageTopic.open = Topic Details - title.message.add = Add Message title.message.open = View Message title.message.reply = Reply Message +title.message.edit = Edit Message message.label.subject = Subject message.label.body = Body message.label.postedOn = Posted On: message.label.threadReplies = Thread Replies message.link.reply = Reply - ##Labels label.open = Open label.delete = Delete Index: lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/actions/ForumAction.java =================================================================== diff -u -r99cfb2b5001eb3183cc5a43146b6655c65d68efd -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/actions/ForumAction.java (.../ForumAction.java) (revision 99cfb2b5001eb3183cc5a43146b6655c65d68efd) +++ lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/actions/ForumAction.java (.../ForumAction.java) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -11,6 +11,7 @@ import org.lamsfoundation.lams.tool.forum.forms.ForumForm; import org.lamsfoundation.lams.tool.forum.forms.MessageForm; import org.lamsfoundation.lams.tool.forum.util.ContentHandler; +import org.lamsfoundation.lams.contentrepository.CrNodeVersionProperty; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -104,7 +105,6 @@ throws IOException, ServletException, Exception { ForumForm forumForm = (ForumForm) form; Forum forum = forumForm.getForum(); - Map topics = (Map) request.getSession().getAttribute("topics"); this.forumManager.editForum(forum, forumForm.getAttachments(), topics); return mapping.findForward("success"); @@ -132,6 +132,30 @@ request.getSession().setAttribute("topics", topics); request.getSession().setAttribute("topicList", topicList); + + List attachmentList = new ArrayList(); + Collection entries = forum.getAttachments(); + it = entries.iterator(); + while (it.hasNext()) { + Attachment attachment = (Attachment) it.next(); + ContentHandler handler = new ContentHandler(); + Set properties = handler.getFileProperties(attachment.getUuid()); + Iterator propIt = properties.iterator(); + while (propIt.hasNext()) { + CrNodeVersionProperty property = (CrNodeVersionProperty) propIt.next(); + if ("FILENAME".equals(property.getName())) { + attachment.setName(property.getValue()); + } + if ("TYPE".equals(property.getName())) { + attachment.setType(property.getValue()); + } + if ("MIMETYPE".equals(property.getName())) { + attachment.setContentType(property.getValue()); + } + } + attachmentList.add(attachment); + } + request.getSession().setAttribute("attachmentList", attachmentList); return mapping.findForward("success"); } @@ -178,13 +202,12 @@ ActionForward forward = new ActionForward(); forward.setPath(mapping.getInput()); String fileName = (String) request.getParameter("fileName"); + String type = (String) request.getParameter("type"); ForumForm forumForm = (ForumForm) form; Map attachments = forumForm.getAttachments(); - Attachment attachment = (Attachment) attachments.remove(fileName); - ContentHandler handler = ContentHandler.getInstance(); - //File file = ContentHandler.getFile(attachment.getName(), attachment.getUuid()); + Attachment attachment = (Attachment) attachments.remove(fileName + "-" + type); ContentHandler.deleteFile(attachment.getUuid()); - if (attachment.getId() !=null) { + if (attachment.getId() != null) { this.forumManager.deleteForumAttachment(attachment.getId()); } List attachmentList = new ArrayList(attachments.values()); Index: lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/actions/LearningAction.java =================================================================== diff -u -rda429cada8bdb32348ca0f8b7ab64ec755f63c8f -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/actions/LearningAction.java (.../LearningAction.java) (revision da429cada8bdb32348ca0f8b7ab64ec755f63c8f) +++ lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/actions/LearningAction.java (.../LearningAction.java) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -12,6 +12,9 @@ import org.lamsfoundation.lams.tool.forum.persistence.Message; import org.lamsfoundation.lams.tool.forum.forms.ForumForm; import org.lamsfoundation.lams.tool.forum.forms.MessageForm; +import org.lamsfoundation.lams.tool.forum.permissions.Permission; +import org.lamsfoundation.lams.tool.forum.permissions.PermissionManagerImpl; +import org.lamsfoundation.lams.tool.forum.permissions.PermissionManager; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -29,15 +32,14 @@ public class LearningAction extends Action { private static Logger log = Logger.getLogger(LearningAction.class.getName()); private ForumManager forumManager; + private PermissionManager permissionManager; - public void setForumManager(ForumManager forumManager) { - this.forumManager = forumManager; - } public LearningAction() { this.forumManager = (ForumManager) GenericObjectFactoryImpl.getInstance().lookup("forumManager"); - //GenericObjectFactoryImpl.getInstance().configure(this); + this.permissionManager = (PermissionManager) GenericObjectFactoryImpl.getInstance().lookup("permissionManager"); } + public final ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String param = mapping.getParameter(); @@ -47,7 +49,10 @@ if (param.equals("editMessage")) { return editMessage(mapping, form, request, response); } - if (param.equals("openMessage")) { + if (param.equals("openTopic")) { + return getTopic(mapping, form, request, response); + } + if (param.equals("getMessage")) { return getMessage(mapping, form, request, response); } if (param.equals("deleteMessage")) { @@ -100,7 +105,8 @@ throws IOException, ServletException, PersistenceException { MessageForm messageForm = (MessageForm) form; Message message = messageForm.getMessage(); - this.forumManager.editMessage(message); + message = this.forumManager.editMessage(message); + request.setAttribute("topicId", messageForm.getTopicId()); return mapping.findForward("success"); } @@ -129,23 +135,43 @@ return mapping.findForward("success"); } - public ActionForward getMessage(ActionMapping mapping, + public ActionForward getTopic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException, Exception { Long topicId = new Long((String) request.getParameter("topicId")); - - /* - Long messageId = new Long((String) request.getParameter("parentId")); - Message message = forumManager.getMessage(messageId); - */ - Message message = forumManager.getMessage(topicId); request.setAttribute("message", message); + Long userId = null; + try { + userId = new Long((String) request.getParameter("userId")); + } catch (Exception e) { + //will always be null for now as we are handling tool independently from user for now later we have to get + //the current logged used from the session + } + boolean moderate = permissionManager.hasPermission(userId, Permission.MODERATE); + String permissionType = Permission.WRITE; + if (moderate) { + permissionType = Permission.MODERATE; + } + request.setAttribute("permission", permissionType); return mapping.findForward("success"); + } + + public ActionForward getMessage(ActionMapping mapping, + ActionForm form, + HttpServletRequest request, + HttpServletResponse response) + throws IOException, ServletException, Exception { + Long topicId = new Long((String) request.getParameter("topicId")); + Long messageId = new Long((String) request.getParameter("messageId")); + Message message = forumManager.getMessage(messageId); + MessageForm messageForm = new MessageForm(); + messageForm.setMessage(message); + messageForm.setTopicId(topicId); + request.setAttribute("messageForm", messageForm); + return mapping.findForward("success"); } - - } Index: lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/forms/ForumForm.java =================================================================== diff -u -r99cfb2b5001eb3183cc5a43146b6655c65d68efd -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/forms/ForumForm.java (.../ForumForm.java) (revision 99cfb2b5001eb3183cc5a43146b6655c65d68efd) +++ lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/forms/ForumForm.java (.../ForumForm.java) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -20,6 +20,7 @@ * * Message Form. * @struts.form name="forumForm" + * * Created by IntelliJ IDEA. * User: conradb * Date: 10/06/2005 @@ -32,8 +33,8 @@ private FormFile onlineFile; protected Map attachments; protected boolean lockWhenFinished; - protected boolean forceOffline; - protected boolean allowAnnomity; + protected boolean forceOffline; + protected boolean allowAnnomity; protected ContentHandler contentHander; private static Logger logger = Logger.getLogger(ForumForm.class.getName()); @@ -93,64 +94,65 @@ } public void setAttachments(Map attachments) { - this.attachments = attachments; + this.attachments = attachments; } public Map getAttachments() { return this.attachments; } public ActionErrors validate(ActionMapping mapping, - javax.servlet.http.HttpServletRequest request) { - ActionErrors errors = super.validate(mapping, request); + javax.servlet.http.HttpServletRequest request) { + ActionErrors errors = super.validate(mapping, request); ActionError ae; ContentHandler contentHandler; try{ - // if ("".equals(forum.getTitle())) { - // ActionError error = new ActionError("error.valueReqd"); - // errors.add("forum.title", error); - // } - try { - contentHandler = ContentHandler.getInstance(); - } catch (Exception e) { - ae = new ActionError("error.inputFileTooLarge"); - errors.add("onlineFile", ae); - throw e; - } - if (onlineFile != null && !(onlineFile.getFileName().trim().equals(""))) { - if (onlineFile.getFileSize() > ForumConstants.MAX_FILE_SIZE) { - ae = new ActionError("error.inputFileTooLarge"); - errors.add("onlineFile", ae); - } else { - String fileName = onlineFile.getFileName(); + if ("".equals(forum.getTitle())) { + ActionError error = new ActionError("error.valueReqd"); + errors.add("forum.title", error); + } + if (onlineFile != null && !(onlineFile.getFileName().trim().equals(""))) { + if (onlineFile.getFileSize() > ForumConstants.MAX_FILE_SIZE) { + ae = new ActionError("error.inputFileTooLarge"); + errors.add("onlineFile", ae); + } else { + String fileName = onlineFile.getFileName(); + if (!attachments.containsKey(fileName +"-" + Attachment.TYPE_ONLINE)) { NodeKey node = ContentHandler.uploadFile(onlineFile.getInputStream(), fileName, onlineFile.getContentType()); - Attachment attachment = new Attachment(); + ContentHandler.setProperty(node.getUuid(), node.getVersion(), "TYPE", Attachment.TYPE_ONLINE); + Attachment attachment = new Attachment(); attachment.setName(fileName); - attachment.setUuid(node.getUuid()); + attachment.setStream(onlineFile.getInputStream()); + attachment.setUuid(node.getUuid()); attachment.setType(Attachment.TYPE_ONLINE); - attachments.put(fileName, attachment); + attachments.put(fileName + "-" + Attachment.TYPE_ONLINE, attachment); onlineFile = null; - } - } - if (offlineFile != null && !(offlineFile.getFileName().trim().equals(""))) { - if (offlineFile.getFileSize() > ForumConstants.MAX_FILE_SIZE) { - ae = new ActionError("error.inputFileTooLarge"); - errors.add("offlineFile", ae); - } else { - String fileName = offlineFile.getFileName(); - NodeKey node = ContentHandler.uploadFile(onlineFile.getInputStream(), fileName, onlineFile.getContentType()); - Attachment attachment = new Attachment(); + } + } + } + if (offlineFile != null && !(offlineFile.getFileName().trim().equals(""))) { + if (offlineFile.getFileSize() > ForumConstants.MAX_FILE_SIZE) { + ae = new ActionError("error.inputFileTooLarge"); + errors.add("offlineFile", ae); + } else { + String fileName = offlineFile.getFileName(); + if (!attachments.containsKey(fileName +"-" + Attachment.TYPE_OFFLINE)) { + NodeKey node = ContentHandler.uploadFile(offlineFile.getInputStream(), fileName, offlineFile.getContentType()); + ContentHandler.setProperty(node.getUuid(), node.getVersion(), "TYPE", Attachment.TYPE_OFFLINE); + Attachment attachment = new Attachment(); attachment.setName(fileName); + attachment.setStream(offlineFile.getInputStream()); attachment.setUuid(node.getUuid()); attachment.setType(Attachment.TYPE_OFFLINE); - attachments.put(fileName, attachment); + attachments.put(fileName + "-" + Attachment.TYPE_OFFLINE, attachment); offlineFile = null; - } - } - } catch (Exception e) { - logger.error("", e); - } - return errors; - } + } + } + } + } catch (Exception e) { + logger.error("", e); + } + return errors; + } } Index: lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/util/MessageMapTag.java =================================================================== diff -u -r1c7217cd439dfafc738d8df7aad850b3eed802d5 -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/util/MessageMapTag.java (.../MessageMapTag.java) (revision 1c7217cd439dfafc738d8df7aad850b3eed802d5) +++ lams_tool_forum/web/WEB-INF/classes/org/lamsfoundation/lams/tool/forum/util/MessageMapTag.java (.../MessageMapTag.java) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -1,6 +1,7 @@ package org.lamsfoundation.lams.tool.forum.util; import org.lamsfoundation.lams.tool.forum.persistence.Message; +import org.lamsfoundation.lams.tool.forum.permissions.Permission; import javax.servlet.jsp.tagext.TagSupport; import javax.servlet.jsp.JspException; @@ -23,8 +24,8 @@ private Logger log = Logger.getLogger(MessageMapTag.class.getName()); private Set replies = null; - private String ordered = "ul"; - private String path; + private String path=""; + private String mode; private String topicId; private SimpleDateFormat formatter = new SimpleDateFormat("dd:MM:yy hh:mm a"); @@ -45,10 +46,8 @@ this.replies = replies; } - public void setOrdered(String ordered) { - if (ordered.equals("true")) { - this.ordered = "ol"; - } + public void setMode(String mode) { + this.mode = mode; } /** @@ -71,18 +70,8 @@ String output = ""; Iterator it = replies.iterator(); - /* while (it.hasNext()) { - output = output + "<" + ordered + ">" + getThreadView((Message) it.next()) - + "\n"; - } - output = output + "

"; - //output = output + " "; - it = replies.iterator(); - */ - - while (it.hasNext()) { - String indentPrefix = "
\n"; + String indentPrefix = "
\n"; String indentPostfix = "
\n

\n"; int level = 0; output = output + this.getIndentedView(level, indentPrefix, indentPostfix, (Message) it.next()); @@ -102,75 +91,70 @@ public void release() { super.release(); replies = null; - ordered = "ul"; } - private StringBuffer getThreadView(Message reply) throws Exception { - StringBuffer buffer = new StringBuffer(); - - buffer.append("\n
  • "); - buffer.append(reply.getBody()); - buffer.append(""); - buffer.append(" - "); - buffer.append(formatter.format(reply.getCreated())); - Set subReplies = reply.getReplies(); - - if (subReplies != null) { - buffer.append("\n<"); - buffer.append(ordered); - buffer.append(">"); - Iterator it = subReplies.iterator(); - while (it.hasNext()) { - buffer.append(getThreadView((Message) it.next())); - } - buffer.append("\n"); - } - buffer.append("
  • "); - return buffer; - } - private StringBuffer getIndentedView(int level, String indentPrefix, String indentPostfix, Message reply) throws Exception { StringBuffer buffer = new StringBuffer(); buffer.append(indentPrefix); buffer.append("\n"); + + //Creadted By Link buffer.append("\n"); if (reply.getCreatedBy() == null) { buffer.append("Anonymous\n"); } else { buffer.append("" + reply.getCreatedBy() + "\n"); } buffer.append("\n"); + + //Created Date buffer.append("\n"); buffer.append("" + formatter.format(reply.getCreated()) + "\n"); buffer.append("\n"); - buffer.append("\n"); - buffer.append(""); - buffer.append("Reply"); - buffer.append("\n"); - buffer.append("\n"); + + //Edit Link + if (Permission.MODERATE.equals(mode)) { + buffer.append("\n"); + //buffer.append(""); + buffer.append("Edit"); + buffer.append("\n"); + buffer.append("\n"); + } + + //Reply To Link + if (Permission.MODERATE.equals(mode) || Permission.WRITE.equals(mode)) { + buffer.append("\n"); + buffer.append(""); + buffer.append("Reply"); + buffer.append("\n"); + buffer.append("\n"); + } + + //Body of Message buffer.append("\n"); - buffer.append("\n"); + buffer.append("\n"); buffer.append(reply.getBody()); buffer.append("\n"); buffer.append("\n"); + + //Intented Replies of the Messages buffer.append(indentPostfix); Iterator it = reply.getReplies().iterator(); level = level + 2; while (it.hasNext()) { StringBuffer preFix = new StringBuffer(); - preFix.append("\n"); + preFix.append("
    \n"); preFix.append("\n"); preFix.append("\n"); Index: lams_tool_forum/web/WEB-INF/jsps/authoring/forum/editInstructions.jsp =================================================================== diff -u -r282fd2069a1e0bf88219274af0604853c8763d69 -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/jsps/authoring/forum/editInstructions.jsp (.../editInstructions.jsp) (revision 282fd2069a1e0bf88219274af0604853c8763d69) +++ lams_tool_forum/web/WEB-INF/jsps/authoring/forum/editInstructions.jsp (.../editInstructions.jsp) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -39,8 +39,9 @@ - - + + +
    \n"); preFix.append(""); - preFix.append("\n"); - + preFix.append("
    \n"); StringBuffer postFix = new StringBuffer(); postFix.append("
    \n"); postFix.append("
    Index: lams_tool_forum/web/WEB-INF/jsps/authoring/forum/instructions.jsp =================================================================== diff -u -r282fd2069a1e0bf88219274af0604853c8763d69 -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/jsps/authoring/forum/instructions.jsp (.../instructions.jsp) (revision 282fd2069a1e0bf88219274af0604853c8763d69) +++ lams_tool_forum/web/WEB-INF/jsps/authoring/forum/instructions.jsp (.../instructions.jsp) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -39,7 +39,9 @@ - + + + Index: lams_tool_forum/web/WEB-INF/jsps/learning/forum/open.jsp =================================================================== diff -u -r059e321032f885ded2d68727192dcdcf44a1f30a -r3e3add3c256312ab7933ee442a54272eae80a8ea --- lams_tool_forum/web/WEB-INF/jsps/learning/forum/open.jsp (.../open.jsp) (revision 059e321032f885ded2d68727192dcdcf44a1f30a) +++ lams_tool_forum/web/WEB-INF/jsps/learning/forum/open.jsp (.../open.jsp) (revision 3e3add3c256312ab7933ee442a54272eae80a8ea) @@ -29,7 +29,7 @@ - +