Index: lams_tool_larsrc/conf/language/ApplicationResources.properties =================================================================== diff -u -r754e5e666cf510aff7f8f25527987cee00319ee2 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 754e5e666cf510aff7f8f25527987cee00319ee2) +++ lams_tool_larsrc/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -84,6 +84,16 @@ error.resource.item.file.blank = File can not be blank. error.resource.item.desc.blank= Description can not be blank error.resource.item.invalid.url= Invalid URL format. +error.upload.failed=Upload file failed: {0} +error.msg.upload.file.not.found=Could not find upload file {0}. +error.msg.zip.file.exception=Could not handle zip file when uploading file. +error.msg.file.not.found=File not found exception occurs when uploading file. +error.msg.ims.package=Invalid IMS package format. +error.msg.ims.application=ImscpApplicationException occurs when uploading resource item file. +error.msg.io.exception=IOException occurs when uploading file. +error.msg.invaid.param.upload=InvalidParameterException occured while trying to upload File. +error.msg.repository=Repository occurs exception while trying to upload file. +error.msg.default.content.not.find=Could not retrieve default content record for this tool. authoring.save.success=Authoring save successfully. #-------------------------END Authoring Labels END-----------------# Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/ResourceConstants.java =================================================================== diff -u -rf644eb2a669882b4938c6b49bb0441e70bb7adb9 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/ResourceConstants.java (.../ResourceConstants.java) (revision f644eb2a669882b4938c6b49bb0441e70bb7adb9) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/ResourceConstants.java (.../ResourceConstants.java) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -59,6 +59,7 @@ public static final String ERROR_MSG_DESC_BLANK = "error.resource.item.desc.blank"; public static final String ERROR_MSG_FILE_BLANK = "error.resource.item.file.blank"; public static final String ERROR_MSG_INVALID_URL = "error.resource.item.invalid.url"; + public static final String ERROR_MSG_UPLOAD_FAILED = "error.upload.failed"; //mode public static final String MODE = "mode"; Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/model/ResourceItem.hbm.xml =================================================================== diff -u -r0c4f17efc49e7012360fb98ac98b7e4a005fea9f -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/model/ResourceItem.hbm.xml (.../ResourceItem.hbm.xml) (revision 0c4f17efc49e7012360fb98ac98b7e4a005fea9f) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/model/ResourceItem.hbm.xml (.../ResourceItem.hbm.xml) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -67,7 +67,7 @@ instructionList, ResourceItemForm itemForm) - throws ResourceApplicationException { + throws UploadResourceFileException { /* BE CAREFUL: This method will copy nessary info from request form to a old or new ResourceItem instance. * It gets all info EXCEPT ResourceItem.createDate and ResourceItem.createBy, which need be set when persisting * this resource item. @@ -811,7 +824,51 @@ }else //edit item = (ResourceItem) resourceList.get(itemIdx); + short type = itemForm.getItemType(); item.setType(itemForm.getItemType()); + /* Set following fields regards to the type: + item.setFileUuid(); + item.setFileVersionId(); + item.setFileType(); + item.setFileName(); + + item.getInitialItem() + item.setImsSchema() + item.setOrganizationXml() + */ + //if the item is edit (not new add) then the getFile may return null + //it may throw exception, so put it as first, to avoid other invlidate update: + if(itemForm.getFile() != null){ + if(type == ResourceConstants.RESOURCE_TYPE_WEBSITE + ||type == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT + ||type == ResourceConstants.RESOURCE_TYPE_FILE){ + //if it has old file, and upload a new, then save old to deleteList + ResourceItem delAttItem = new ResourceItem(); + boolean hasOld = false; + if(item.getFileUuid() != null){ + hasOld = true; + //be careful, This new ResourceItem object never be save into database + //just temporarily use for saving fileUuid and versionID use: + delAttItem.setFileUuid(item.getFileUuid()); + delAttItem.setFileVersionId(item.getFileVersionId()); + } + IResourceService service = getResourceService(); + try { + service.uploadResourceItemFile(item, itemForm.getFile()); + } catch (UploadResourceFileException e) { + //if it is new add , then remove it! + if(itemIdx == -1){ + resourceList.remove(item); + } + throw e; + } + //put it after "upload" to ensure deleted file added into list only no exception happens during upload + if(hasOld){ + List delAtt = getDeletedItemAttachmentList(request); + delAtt.add(delAttItem); + } + } + } item.setTitle(itemForm.getTitle()); item.setCreateByAuthor(true); item.setHide(false); @@ -825,44 +882,15 @@ instructions.add(rii); } item.setItemInstructions(instructions); - - short type = itemForm.getItemType(); + if(type == ResourceConstants.RESOURCE_TYPE_URL){ item.setUrl(itemForm.getUrl()); } if(type == ResourceConstants.RESOURCE_TYPE_WEBSITE ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT){ item.setDescription(itemForm.getDescription()); } - /* Set following fields regards to the type: - item.setFileUuid(); - item.setFileVersionId(); - item.setFileType(); - item.setFileName(); - - item.getInitialItem() - item.setImsSchema() - item.setOrganizationXml() - */ - //if the item is edit (not new add) then the getFile may return null - if(itemForm.getFile() != null){ - if(type == ResourceConstants.RESOURCE_TYPE_WEBSITE - ||type == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT - ||type == ResourceConstants.RESOURCE_TYPE_FILE){ - //if it has old file, and upload a new, then save old to deleteList - if(item.getFileUuid() != null){ - List delAtt = getDeletedItemAttachmentList(request); - //be careful, This new ResourceItem object never be save into database - //just temporarily use for saving fileUuid and versionID use: - ResourceItem delAttItem = new ResourceItem(); - delAttItem.setFileUuid(item.getFileUuid()); - delAttItem.setFileVersionId(item.getFileVersionId()); - delAtt.add(delAttItem); - } - IResourceService service = getResourceService(); - service.uploadResourceItemFile(item, itemForm.getFile()); - } - } + } /** @@ -890,7 +918,9 @@ if(itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_WEBSITE ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_LEARNING_OBJECT ||itemForm.getItemType() == ResourceConstants.RESOURCE_TYPE_FILE){ - if(itemForm.getFile() == null || StringUtils.isEmpty(itemForm.getFile().getFileName())) + //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/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceForm.java =================================================================== diff -u -rf644eb2a669882b4938c6b49bb0441e70bb7adb9 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceForm.java (.../ResourceForm.java) (revision f644eb2a669882b4938c6b49bb0441e70bb7adb9) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceForm.java (.../ResourceForm.java) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -90,6 +90,20 @@ logger.error("Initial ResourceForum failed by null value of Resource."); } } + public void reset(ActionMapping mapping, HttpServletRequest request){ + String param = mapping.getParameter(); + //if it is start page, all data read out from database or current session + //so need not reset checkbox to refresh value! + if(!StringUtils.equals(param,"start") && !StringUtils.equals(param,"initPage")){ + resource.setAllowAddFiles(false); + resource.setAllowAddUrls(false); + resource.setLockWhenFinished(false); + resource.setDefineLater(false); + resource.setRunAuto(false); + resource.setRunOffline(false); + } + } + public int getCurrentTab() { return currentTab; } Index: lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceItemForm.java =================================================================== diff -u -r754e5e666cf510aff7f8f25527987cee00319ee2 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceItemForm.java (.../ResourceItemForm.java) (revision 754e5e666cf510aff7f8f25527987cee00319ee2) +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceItemForm.java (.../ResourceItemForm.java) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -38,6 +38,7 @@ private short itemType; private String description; private String url; + //flag of this item has attachment or not private boolean hasFile; private Long fileUuid; private Long fileVersionId; Index: lams_tool_larsrc/web/common/defaultFrame.jsp =================================================================== diff -u -r65166da92a6f0f4ff73acb92b95672e237b25742 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/web/common/defaultFrame.jsp (.../defaultFrame.jsp) (revision 65166da92a6f0f4ff73acb92b95672e237b25742) +++ lams_tool_larsrc/web/common/defaultFrame.jsp (.../defaultFrame.jsp) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -17,7 +17,7 @@ USA http://www.gnu.org/licenses/gpl.txt ---> +--%> <%@ include file="/common/taglibs.jsp" %> Index: lams_tool_larsrc/web/layout/frame.jsp =================================================================== diff -u -r65166da92a6f0f4ff73acb92b95672e237b25742 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/web/layout/frame.jsp (.../frame.jsp) (revision 65166da92a6f0f4ff73acb92b95672e237b25742) +++ lams_tool_larsrc/web/layout/frame.jsp (.../frame.jsp) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -17,7 +17,7 @@ USA http://www.gnu.org/licenses/gpl.txt ---> +--%> <%@ include file="/common/taglibs.jsp" %> Index: lams_tool_larsrc/web/pages/authoring/advance.jsp =================================================================== diff -u -rf644eb2a669882b4938c6b49bb0441e70bb7adb9 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/web/pages/authoring/advance.jsp (.../advance.jsp) (revision f644eb2a669882b4938c6b49bb0441e70bb7adb9) +++ lams_tool_larsrc/web/pages/authoring/advance.jsp (.../advance.jsp) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -46,5 +46,4 @@ -
\ No newline at end of file Index: lams_tool_larsrc/web/pages/authoring/instructions.jsp =================================================================== diff -u -rf644eb2a669882b4938c6b49bb0441e70bb7adb9 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/web/pages/authoring/instructions.jsp (.../instructions.jsp) (revision f644eb2a669882b4938c6b49bb0441e70bb7adb9) +++ lams_tool_larsrc/web/pages/authoring/instructions.jsp (.../instructions.jsp) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -116,5 +116,4 @@ - \ No newline at end of file Index: lams_tool_larsrc/web/pages/authoring/parts/itemattachment.jsp =================================================================== diff -u -rf644eb2a669882b4938c6b49bb0441e70bb7adb9 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/web/pages/authoring/parts/itemattachment.jsp (.../itemattachment.jsp) (revision f644eb2a669882b4938c6b49bb0441e70bb7adb9) +++ lams_tool_larsrc/web/pages/authoring/parts/itemattachment.jsp (.../itemattachment.jsp) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -1,5 +1,6 @@ <%@ include file="/common/taglibs.jsp" %> + Index: lams_tool_larsrc/web/pages/learningobj/navigatortree.jsp =================================================================== diff -u -r65166da92a6f0f4ff73acb92b95672e237b25742 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/web/pages/learningobj/navigatortree.jsp (.../navigatortree.jsp) (revision 65166da92a6f0f4ff73acb92b95672e237b25742) +++ lams_tool_larsrc/web/pages/learningobj/navigatortree.jsp (.../navigatortree.jsp) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -17,7 +17,7 @@ USA http://www.gnu.org/licenses/gpl.txt ---> +--%> <%@ include file="/common/taglibs.jsp" %> Index: lams_tool_larsrc/web/pages/learningobj/xmltree.xsl =================================================================== diff -u -r65166da92a6f0f4ff73acb92b95672e237b25742 -r80c80183c1497f0ba84e9ab1fa78a2fbb369ef65 --- lams_tool_larsrc/web/pages/learningobj/xmltree.xsl (.../xmltree.xsl) (revision 65166da92a6f0f4ff73acb92b95672e237b25742) +++ lams_tool_larsrc/web/pages/learningobj/xmltree.xsl (.../xmltree.xsl) (revision 80c80183c1497f0ba84e9ab1fa78a2fbb369ef65) @@ -1,6 +1,6 @@ -<%-- +