Index: lams_tool_forum/conf/language/ApplicationResources.properties =================================================================== diff -u -r99c920d6a9d32eb5bf47bcbba06c03b027f5b786 -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_forum/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 99c920d6a9d32eb5bf47bcbba06c03b027f5b786) +++ lams_tool_forum/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -170,4 +170,5 @@ #======= End labels: Exported 160 labels for en AU ===== -message.no.reflection.available = No notebook available \ No newline at end of file +message.no.reflection.available = No notebook available +errors.maxfilesize =The uploaded file has exceeded the maximum file size limit of {0} bytes \ No newline at end of file Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java =================================================================== diff -u -rd2bd2447935a6088d331c661602630854ecc37a5 -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision d2bd2447935a6088d331c661602630854ecc37a5) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -25,6 +25,8 @@ package org.lamsfoundation.lams.tool.forum.web.actions; +import static org.lamsfoundation.lams.tool.forum.util.ForumConstants.OLD_FORUM_STYLE; + import java.io.IOException; import java.util.ArrayList; import java.util.Date; @@ -66,14 +68,13 @@ import org.lamsfoundation.lams.tool.forum.web.forms.ForumForm; import org.lamsfoundation.lams.tool.forum.web.forms.MessageForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; -import org.lamsfoundation.lams.util.UploadFileUtil; +import org.lamsfoundation.lams.util.FileValidatorUtil; 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; -import static org.lamsfoundation.lams.tool.forum.util.ForumConstants.OLD_FORUM_STYLE; /** * @author Steve.Ni @@ -449,6 +450,12 @@ if(file == null || StringUtils.isBlank(file.getFileName())) return mapping.findForward("success"); + ActionMessages errors = new ActionMessages(); + FileValidatorUtil.validateFileSize(file, true, errors ); + if(!errors.isEmpty()){ + this.saveErrors(request, errors); + return mapping.findForward("success"); + } forumService = getForumManager(); //upload to repository @@ -938,16 +945,7 @@ errors.add(ActionMessages.GLOBAL_MESSAGE, error); } } - if (form.getOnlineFile() != null && !(form.getOnlineFile().getFileName().trim().equals("")) - && convertToMeg(form.getOnlineFile().getFileSize()) > UploadFileUtil.getMaxFileSize()) { - ae = new ActionMessage("error.inputFileTooLarge"); - errors.add(ActionMessages.GLOBAL_MESSAGE, ae); - } - if (form.getOfflineFile() != null && !(form.getOfflineFile().getFileName().trim().equals("")) - && convertToMeg(form.getOfflineFile().getFileSize()) > UploadFileUtil.getMaxFileSize()) { - ae = new ActionMessage("error.inputFileTooLarge"); - errors.add(ActionMessages.GLOBAL_MESSAGE, ae); - } + } catch (Exception e) { log.error(e.toString()); } Index: lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java =================================================================== diff -u -reb6d30f3b815b7e8154c23495e796c68f43fbb7f -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java (.../MessageForm.java) (revision eb6d30f3b815b7e8154c23495e796c68f43fbb7f) +++ lams_tool_forum/src/java/org/lamsfoundation/lams/tool/forum/web/forms/MessageForm.java (.../MessageForm.java) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -34,6 +34,7 @@ import org.apache.struts.validator.ValidatorForm; import org.lamsfoundation.lams.tool.forum.persistence.Attachment; import org.lamsfoundation.lams.tool.forum.persistence.Message; +import org.lamsfoundation.lams.util.FileValidatorUtil; /** * @@ -79,6 +80,15 @@ ActionMessage error = new ActionMessage("error.body.required"); errors.add("message.body", error); } + + +// validate item size + boolean largeFile = true; + if(request.getRequestURI().indexOf("/learning/") != -1) + largeFile = false; + + FileValidatorUtil.validateFileSize(this.getAttachmentFile(), largeFile,"message.attachment", errors ); + } catch (Exception e) { logger.error("", e); } Index: lams_tool_forum/web/jsps/authoring/message/create.jsp =================================================================== diff -u -r9b2c0bcea9343b234ed746093ecb13c3ff636701 -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_forum/web/jsps/authoring/message/create.jsp (.../create.jsp) (revision 9b2c0bcea9343b234ed746093ecb13c3ff636701) +++ lams_tool_forum/web/jsps/authoring/message/create.jsp (.../create.jsp) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -15,8 +15,7 @@ enctype="multipart/form-data" styleId="topicFormId"> + value="<%=request.getAttribute(org.apache.struts.taglib.html.Constants.BEAN_KEY)%>" /> @@ -35,7 +34,11 @@
- + + + +
@@ -45,7 +48,8 @@
- +
+
Index: lams_tool_forum/web/jsps/learning/message/topicform.jsp =================================================================== diff -u -rdcb83f95aa4dea687ccdf61672668086b712b9a0 -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_forum/web/jsps/learning/message/topicform.jsp (.../topicform.jsp) (revision dcb83f95aa4dea687ccdf61672668086b712b9a0) +++ lams_tool_forum/web/jsps/learning/message/topicform.jsp (.../topicform.jsp) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -19,7 +19,7 @@ - +
Index: lams_tool_nb/conf/language/ApplicationResources.properties =================================================================== diff -u -r19be54d4ab8af4ef6e1fdb487e9e253f3478916d -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_nb/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 19be54d4ab8af4ef6e1fdb487e9e253f3478916d) +++ lams_tool_nb/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -64,3 +64,4 @@ label.edit = Edit message.no.reflection.available = No notebook available +errors.maxfilesize =The uploaded file has exceeded the maximum file size limit of {0} bytes \ No newline at end of file Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java =================================================================== diff -u -r2a6d3a91cb4cf1c169518fe434154f645fabd602 -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java (.../NbAuthoringAction.java) (revision 2a6d3a91cb4cf1c169518fe434154f645fabd602) +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java (.../NbAuthoringAction.java) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -56,6 +56,7 @@ import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.FileValidatorUtil; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsLookupDispatchAction; import org.lamsfoundation.lams.web.session.SessionManager; @@ -350,7 +351,16 @@ //throws exception if the content id does not exist checkContentId(content_id); NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id); - + + //validate file max size + ActionMessages errors = new ActionMessages(); + FileValidatorUtil.validateFileSize(nbForm.getOnlineFile(), true, errors ); + FileValidatorUtil.validateFileSize(nbForm.getOfflineFile(), true, errors ); + if(!errors.isEmpty()){ + this.saveErrors(request, errors); + return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE); + } + //check if the file uploaded is an online instructions file or offline instructions file. //if one of the types is null, then the other one must have been uploaded. //here we check if the file is an online one Index: lams_tool_nb/web/authoring/authoring.jsp =================================================================== diff -u -r6e8d0f5d2d331dab6cebec11f2833c5147870dad -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_nb/web/authoring/authoring.jsp (.../authoring.jsp) (revision 6e8d0f5d2d331dab6cebec11f2833c5147870dad) +++ lams_tool_nb/web/authoring/authoring.jsp (.../authoring.jsp) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -69,7 +69,7 @@ .getAttribute(org.apache.struts.taglib.html.Constants.BEAN_KEY)%>" /> - + <%-- in define later mode we edit only the basic content. But if we don't have the instructions tab, then the instructions are lost when saving. --%>

@@ -88,7 +88,14 @@
- <%@ include file="../errorbox.jsp"%> + +

+ +
+
+

+
+ Index: lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/AuthoringAction.java =================================================================== diff -u -rda54b82e5ef860fe9f8872b75f2b1718cfb7de32 -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision da54b82e5ef860fe9f8872b75f2b1718cfb7de32) +++ lams_tool_notebook/src/java/org/lamsfoundation/lams/tool/notebook/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -39,6 +39,7 @@ import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; +import org.apache.struts.action.ActionMessages; import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.authoring.web.AuthoringConstants; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; @@ -49,6 +50,7 @@ import org.lamsfoundation.lams.tool.notebook.service.NotebookServiceProxy; import org.lamsfoundation.lams.tool.notebook.util.NotebookConstants; import org.lamsfoundation.lams.tool.notebook.web.forms.AuthoringForm; +import org.lamsfoundation.lams.util.FileValidatorUtil; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -265,6 +267,16 @@ savedFiles = getAttList(KEY_ONLINE_FILES, map); } + + //validate file max size + ActionMessages errors = new ActionMessages(); + FileValidatorUtil.validateFileSize(file, true, errors ); + if(!errors.isEmpty()){ + request.setAttribute(NotebookConstants.ATTR_SESSION_MAP, map); + this.saveErrors(request, errors); + return mapping.findForward("success"); + } + if (file.getFileName().length() != 0) { // upload file to repository Index: lams_tool_notebook/web/pages/authoring/authoring.jsp =================================================================== diff -u -r5e2d4a2d74479d27d024a7f32994f35bad5c68f1 -rbd376d76233dad7d0a0775762385918fcbb96f4c --- lams_tool_notebook/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 5e2d4a2d74479d27d024a7f32994f35bad5c68f1) +++ lams_tool_notebook/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision bd376d76233dad7d0a0775762385918fcbb96f4c) @@ -39,6 +39,13 @@ + +

+ +
+
+

+