Index: lams_tool_larsrc/conf/language/ApplicationResources.properties =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/conf/language/Attic/ApplicationResources.properties,v diff -u -r1.4 -r1.5 --- lams_tool_larsrc/conf/language/ApplicationResources.properties 6 Apr 2006 06:58:12 -0000 1.4 +++ lams_tool_larsrc/conf/language/ApplicationResources.properties 10 Apr 2006 07:15:15 -0000 1.5 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/ResourceConstants.java,v diff -u -r1.9 -r1.10 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/ResourceConstants.java 7 Apr 2006 07:25:31 -0000 1.9 +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/ResourceConstants.java 10 Apr 2006 07:15:15 -0000 1.10 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/model/Attic/ResourceItem.hbm.xml,v diff -u -r1.6 -r1.7 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/model/ResourceItem.hbm.xml 5 Apr 2006 07:01:29 -0000 1.6 +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/model/ResourceItem.hbm.xml 10 Apr 2006 07:15:15 -0000 1.7 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceForm.java,v diff -u -r1.6 -r1.7 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceForm.java 7 Apr 2006 07:25:31 -0000 1.6 +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceForm.java 10 Apr 2006 07:15:15 -0000 1.7 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceItemForm.java,v diff -u -r1.4 -r1.5 --- lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceItemForm.java 6 Apr 2006 06:58:12 -0000 1.4 +++ lams_tool_larsrc/src/java/org/lamsfoundation/lams/tool/rsrc/web/form/ResourceItemForm.java 10 Apr 2006 07:15:15 -0000 1.5 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/web/common/Attic/defaultFrame.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_larsrc/web/common/defaultFrame.jsp 7 Apr 2006 00:46:23 -0000 1.2 +++ lams_tool_larsrc/web/common/defaultFrame.jsp 10 Apr 2006 07:15:15 -0000 1.3 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/web/layout/Attic/frame.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_larsrc/web/layout/frame.jsp 7 Apr 2006 00:46:23 -0000 1.2 +++ lams_tool_larsrc/web/layout/frame.jsp 10 Apr 2006 07:15:15 -0000 1.3 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/web/pages/authoring/advance.jsp,v diff -u -r1.3 -r1.4 --- lams_tool_larsrc/web/pages/authoring/advance.jsp 7 Apr 2006 07:25:31 -0000 1.3 +++ lams_tool_larsrc/web/pages/authoring/advance.jsp 10 Apr 2006 07:15:15 -0000 1.4 @@ -46,5 +46,4 @@ -
\ No newline at end of file Index: lams_tool_larsrc/web/pages/authoring/instructions.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/web/pages/authoring/Attic/instructions.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_larsrc/web/pages/authoring/instructions.jsp 7 Apr 2006 07:25:31 -0000 1.2 +++ lams_tool_larsrc/web/pages/authoring/instructions.jsp 10 Apr 2006 07:15:15 -0000 1.3 @@ -116,5 +116,4 @@ - \ No newline at end of file Index: lams_tool_larsrc/web/pages/authoring/parts/itemattachment.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/web/pages/authoring/parts/itemattachment.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_larsrc/web/pages/authoring/parts/itemattachment.jsp 7 Apr 2006 07:25:31 -0000 1.2 +++ lams_tool_larsrc/web/pages/authoring/parts/itemattachment.jsp 10 Apr 2006 07:15:15 -0000 1.3 @@ -1,5 +1,6 @@ <%@ include file="/common/taglibs.jsp" %> + Index: lams_tool_larsrc/web/pages/learningobj/navigatortree.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/web/pages/learningobj/navigatortree.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_larsrc/web/pages/learningobj/navigatortree.jsp 7 Apr 2006 00:46:23 -0000 1.2 +++ lams_tool_larsrc/web/pages/learningobj/navigatortree.jsp 10 Apr 2006 07:15:15 -0000 1.3 @@ -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 =================================================================== RCS file: /usr/local/cvsroot/lams_tool_larsrc/web/pages/learningobj/xmltree.xsl,v diff -u -r1.2 -r1.3 --- lams_tool_larsrc/web/pages/learningobj/xmltree.xsl 7 Apr 2006 00:46:23 -0000 1.2 +++ lams_tool_larsrc/web/pages/learningobj/xmltree.xsl 10 Apr 2006 07:15:15 -0000 1.3 @@ -1,6 +1,6 @@ -<%-- +