Index: lams_tool_larsrc/conf/language/ApplicationResources.properties =================================================================== diff -u -r51ef5c97e4087059671f1bb8bf53dd6a3ca4ee57 -r88329eba8a9d648ae3907adfc06dcce370ea6880 --- lams_tool_larsrc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 51ef5c97e4087059671f1bb8bf53dd6a3ca4ee57) +++ lams_tool_larsrc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 88329eba8a9d648ae3907adfc06dcce370ea6880) @@ -162,3 +162,4 @@ #======= End labels: Exported 153 labels for en AU ===== +errors.maxfilesize =The uploaded file has exceeded the maximum file size limit of {0} bytes \ No newline at end of file Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/AuthoringAction.java =================================================================== diff -u -rd2bd2447935a6088d331c661602630854ecc37a5 -r88329eba8a9d648ae3907adfc06dcce370ea6880 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision d2bd2447935a6088d331c661602630854ecc37a5) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 88329eba8a9d648ae3907adfc06dcce370ea6880) @@ -72,6 +72,7 @@ import org.lamsfoundation.lams.tool.rsrc.web.form.ResourceForm; import org.lamsfoundation.lams.tool.rsrc.web.form.ResourceItemForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +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; @@ -667,6 +668,13 @@ if(file == null || StringUtils.isBlank(file.getFileName())) return mapping.findForward(ResourceConstants.SUCCESS); + //validate file size + ActionMessages errors = new ActionMessages(); + FileValidatorUtil.validateFileSize(file, true, errors ); + if(!errors.isEmpty()){ + this.saveErrors(request, errors); + return mapping.findForward(ResourceConstants.SUCCESS); + } IResourceService service = getResourceService(); //upload to repository @@ -1047,6 +1055,8 @@ if(itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_WEBSITE ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_FILE){ + //validate item size + FileValidatorUtil.validateFileSize(itemForm.getFile(), true, errors ); //for edit validate: file already exist if(!itemForm.isHasFile() && (itemForm.getFile() == null || StringUtils.isEmpty(itemForm.getFile().getFileName()))) @@ -1077,6 +1087,7 @@ // ActionMessage error = new ActionMessage("error.resource.item.title.blank"); // errors.add(ActionMessages.GLOBAL_MESSAGE, error); // } + //define it later mode(TEACHER) skip below validation. String modeStr = request.getParameter(AttributeNames.ATTR_MODE); if(StringUtils.equals(modeStr, ToolAccessMode.TEACHER.toString())){ Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/LearningAction.java =================================================================== diff -u -rd07409f014674f056d1bd67d865ba77f0f8298e9 -r88329eba8a9d648ae3907adfc06dcce370ea6880 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/LearningAction.java (.../LearningAction.java) (revision d07409f014674f056d1bd67d865ba77f0f8298e9) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/action/LearningAction.java (.../LearningAction.java) (revision 88329eba8a9d648ae3907adfc06dcce370ea6880) @@ -63,6 +63,7 @@ import org.lamsfoundation.lams.tool.rsrc.web.form.ReflectionForm; import org.lamsfoundation.lams.tool.rsrc.web.form.ResourceItemForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +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; @@ -584,6 +585,9 @@ if(itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_WEBSITE ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_FILE){ +// validate item size + FileValidatorUtil.validateFileSize(itemForm.getFile(), false, errors ); + //for edit validate: file already exist if(!itemForm.isHasFile() && (itemForm.getFile() == null || StringUtils.isEmpty(itemForm.getFile().getFileName())))