java.util.List
from HttpSession by given name.
+ *
+ * @param request
+ * @param name
+ * @return
+ */
+ private List getListFromSession(HttpServletRequest request,String name) {
+ List list = (List) request.getSession().getAttribute(name);
+ if(list == null){
+ list = new ArrayList();
+ request.getSession().setAttribute(name,list);
+ }
+ return list;
+ }
+ /**
+ * Return ActionForward
according to resource item type.
+ * @param type
+ * @param mapping
+ * @return
+ */
+ private ActionForward findForward(short type, ActionMapping mapping) {
+ ActionForward forward;
+ switch (type) {
+ case ResourceConstants.RESOURCE_TYPE_URL:
+ forward = mapping.findForward("url");
+ break;
+ case ResourceConstants.RESOURCE_TYPE_FILE:
+ forward = mapping.findForward("file");
+ break;
+ case ResourceConstants.RESOURCE_TYPE_WEBSITE:
+ forward = mapping.findForward("website");
+ break;
+ case ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT:
+ forward = mapping.findForward("learningobject");
+ break;
+ default:
+ forward = null;
+ break;
+ }
+ return forward;
+ }
+ /**
+ * @param itemForm
+ * @return
+ */
+ private ActionErrors validateResourceItem(ResourceItemForm itemForm) {
+ ActionErrors errors = new ActionErrors();
+ if(StringUtils.isBlank(itemForm.getTitle()))
+ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(ResourceConstants.ERROR_MSG_TITLE_BLANK));
+
+ if(itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_URL){
+ if(StringUtils.isBlank(itemForm.getUrl()))
+ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(ResourceConstants.ERROR_MSG_URL_BLANK));
+ //URL validation: Commom URL validate(1.3.0) work not very well: it can not support http://address:port format!!!
+// UrlValidator validator = new UrlValidator();
+// if(!validator.isValid(itemForm.getUrl()))
+// errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(ResourceConstants.ERROR_MSG_INVALID_URL));
+ }
+// if(itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_WEBSITE
+// ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT){
+ if(StringUtils.isBlank(itemForm.getDescription()))
+ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(ResourceConstants.ERROR_MSG_DESC_BLANK));
+// }
+ if(itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_WEBSITE
+ ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT
+ ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_FILE){
+ //for edit validate: file already exist
+ if(!itemForm.isHasFile() &&
+ (itemForm.getFile() == null || StringUtils.isEmpty(itemForm.getFile().getFileName())))
+ errors.add(ActionMessages.GLOBAL_MESSAGE,new ActionMessage(ResourceConstants.ERROR_MSG_FILE_BLANK));
+ }
+ return errors;
+ }
+
+
+}
Index: lams_tool_larsrc/web/pages/authoring/parts/addfile.jsp
===================================================================
diff -u -r318b6abe8422efe8b6bac112c6dc0fd15ba13873 -r6b786496dac3e368e8a686373ac4e3cdee391c47
--- lams_tool_larsrc/web/pages/authoring/parts/addfile.jsp (.../addfile.jsp) (revision 318b6abe8422efe8b6bac112c6dc0fd15ba13873)
+++ lams_tool_larsrc/web/pages/authoring/parts/addfile.jsp (.../addfile.jsp) (revision 6b786496dac3e368e8a686373ac4e3cdee391c47)
@@ -12,7 +12,7 @@
-
+