Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardConstants.java,v diff -u -r1.23 -r1.24 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardConstants.java 23 Aug 2006 07:29:07 -0000 1.23 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardConstants.java 6 Sep 2006 01:40:15 -0000 1.24 @@ -102,7 +102,6 @@ public static final String USER_ID = "userID"; public static final String TOOL_SESSION_ID = "toolSessionID"; - public static final String UUID = "uuid"; // --------------------------------------------------------------------------- // Lookup Dispatch Action Keys (used in NbAuthoringAction class, NbLearnerAction), Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardContent.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardContent.java,v diff -u -r1.14 -r1.15 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardContent.java 7 Jun 2006 06:07:21 -0000 1.14 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardContent.java 6 Sep 2006 01:40:15 -0000 1.15 @@ -31,7 +31,6 @@ import java.util.Set; import org.lamsfoundation.lams.contentrepository.ItemNotFoundException; -import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; @@ -393,17 +392,9 @@ while (iter.hasNext()) { NoticeboardAttachment element = (NoticeboardAttachment) iter.next(); NoticeboardAttachment newAttachment = new NoticeboardAttachment(newContent, element.getFilename(), element.isOnlineFile()); - if(toolContentHandler != null){ - //if it is not null, copy file node and refresh uuid and version - NodeKey keys = toolContentHandler.copyFile(element.getUuid()); - newAttachment.setUuid(keys.getUuid()); - newAttachment.setVersionId(keys.getVersion()); - }else{ - //keep old value - newAttachment.setUuid(element.getUuid()); - newAttachment.setVersionId(element.getVersionId()); - } - + // point to the existing tool content + newAttachment.setUuid(element.getUuid()); + newAttachment.setVersionId(element.getVersionId()); newAttachmentSet.add(newAttachment); } newContent.setNbAttachments(newAttachmentSet); Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java,v diff -u -r1.14 -r1.15 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java 6 Apr 2006 07:05:06 -0000 1.14 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java 6 Sep 2006 01:40:15 -0000 1.15 @@ -84,14 +84,16 @@ /** *
Delete the given instance of NoticeboardContent with the
- * given tool content id nbContentId
+ * given tool content id nbContentId
. Does not remove
+ * any attachments as they may be shared with another design.
*
* @param nbContentId The tool content Id.
*/
public void removeNoticeboard(Long nbContentId);
/**
- *
Delete the given instance of NoticeboardContent
+ *Delete the given instance of NoticeboardContent. Does not remove + * any attachments as they may be shared with another design.
* * @param nbContent The instance of NoticeboardContent to delete. */ @@ -302,7 +304,8 @@ public void saveAttachment(NoticeboardContent content, NoticeboardAttachment attachment); /** - * Removes the NoticeboardAttachment object from the database. + * Removes the NoticeboardAttachment object from the database. Does not remove + * the actual file from the content repository as they may be shared with another design. * @param content The overall noticeboard content object to which the attachment is to be added * @param attachment The instance of NoticeboardAttachment to delete. */ @@ -312,7 +315,7 @@ * Add a file to the content repository. Does not add a record to the noticeboard tables. * @throws RepositoryCheckedException */ - public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType) throws RepositoryCheckedException; + public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType, Integer userId) throws RepositoryCheckedException; /** * This method retrieves the default content id. Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java,v diff -u -r1.30 -r1.31 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 29 Aug 2006 04:39:00 -0000 1.30 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 6 Sep 2006 01:40:15 -0000 1.31 @@ -745,7 +745,6 @@ { attachment.setNbContent(null); content.getNbAttachments().remove(attachment); - nbToolContentHandler.deleteFile(attachment.getUuid()); saveNoticeboard(content); } catch (DataAccessException e) @@ -756,10 +755,10 @@ } /** @throws RepositoryCheckedException - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#uploadFile(java.io.InputStream, java.lang.String, java.lang.String, java.lang.String) */ - public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType) throws RepositoryCheckedException + * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#uploadFile(java.io.InputStream, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer) */ + public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType, Integer userId) throws RepositoryCheckedException { - return nbToolContentHandler.uploadFile(istream, filename, contentType, fileType); + return nbToolContentHandler.uploadFile(istream, filename, contentType, fileType, userId); } /* ===============Methods implemented from ToolContentManager =============== */ @@ -926,7 +925,7 @@ exportContentService.registerFileClassForImport(NoticeboardAttachment.class.getName() ,"uuid","versionId","filename","fileProperty",null,null); - Object toolPOJO = exportContentService.importToolContent(toolContentPath,nbToolContentHandler); + Object toolPOJO = exportContentService.importToolContent(toolContentPath,nbToolContentHandler,newUserUid); if(!(toolPOJO instanceof NoticeboardContent)) throw new ImportToolContentException("Import Noteice board tool content failed. Deserialized object is " + toolPOJO); NoticeboardContent toolContentObj = (NoticeboardContent) toolPOJO; @@ -937,7 +936,7 @@ } catch (ImportToolContentException e) { throw new ToolException(e); } - } + } /* ===============Methods implemented from ToolSessionManager =============== */ /** @see org.lamsfoundation.lams.tool.ToolSessionManager#createToolSession(java.lang.Long, java.lang.String, java.lang.Long) */ Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java,v diff -u -r1.29 -r1.30 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 29 Aug 2006 03:33:14 -0000 1.29 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 6 Sep 2006 01:40:15 -0000 1.30 @@ -351,6 +351,8 @@ checkContentId(content_id); NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id); + UserDTO user = getUser(request); + //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 @@ -373,7 +375,7 @@ { // This is a new file and so is saved to the content repository. Add it to the // attachments collection, but don't add it to the tool's tables yet. - NodeKey node = nbService.uploadFile(theFile.getInputStream(), theFile.getFileName(), theFile.getContentType(), fileType); + NodeKey node = nbService.uploadFile(theFile.getInputStream(), theFile.getFileName(), theFile.getContentType(), fileType, user.getUserID()); NoticeboardAttachment file = new NoticeboardAttachment(); file.setFilename(theFile.getFileName()); file.setOnlineFile(isOnlineFile); @@ -456,7 +458,10 @@ public ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws InvalidParameterException, RepositoryCheckedException, NbApplicationException { - Long uuid = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.UUID)); + //set up the values in the map + NbAuthoringForm nbForm = (NbAuthoringForm)form; + + Long uuid = nbForm.getDeleteFileUuid(); if (uuid == null) { String error = "Unable to continue. The file uuid is missing."; @@ -466,7 +471,6 @@ // move the file's details from the attachment collection to the deleted attachments collection // the attachment will be delete on saving. - NbAuthoringForm nbForm = (NbAuthoringForm)form; SessionMap map = getSessionMap(request, nbForm); List attachmentList = (List) map.get(NoticeboardConstants.ATTACHMENT_LIST); List deletedAttachmentList = (List) map.get(NoticeboardConstants.DELETED_ATTACHMENT_LIST); Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java,v diff -u -r1.16 -r1.17 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java 23 Aug 2006 07:29:07 -0000 1.16 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java 6 Sep 2006 01:40:15 -0000 1.17 @@ -85,6 +85,7 @@ private String currentTab; private String sessionMapID; + private Long deleteFileUuid; /** * @return Returns the offlineFile. @@ -230,6 +231,7 @@ this.defineLater = null; this.onlineFile = null; this.offlineFile = null; + this.deleteFileUuid = null; } /** @@ -302,6 +304,11 @@ public void setSessionMapID(String sessionMapID) { this.sessionMapID = sessionMapID; } - + public Long getDeleteFileUuid() { + return deleteFileUuid; + } + public void setDeleteFileUuid(Long deleteFileUuid) { + this.deleteFileUuid = deleteFileUuid; + } } Index: lams_tool_nb/web/authoring/authoring.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/web/authoring/authoring.jsp,v diff -u -r1.11 -r1.12 --- lams_tool_nb/web/authoring/authoring.jsp 4 Sep 2006 07:38:00 -0000 1.11 +++ lams_tool_nb/web/authoring/authoring.jsp 6 Sep 2006 01:40:15 -0000 1.12 @@ -36,6 +36,13 @@ // return false; return true; } + + function deleteAttachment(dispatch, uuid) { + document.authoringForm.dispatch.value = dispatch; + document.authoringForm.deleteFileUuid.value = uuid; + document.authoringForm.submit(); + } + Index: lams_tool_nb/web/authoring/instructions.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/web/authoring/Attic/instructions.jsp,v diff -u -r1.6 -r1.7 --- lams_tool_nb/web/authoring/instructions.jsp 31 Aug 2006 01:31:54 -0000 1.6 +++ lams_tool_nb/web/authoring/instructions.jsp 6 Sep 2006 01:40:15 -0000 1.7 @@ -46,13 +46,10 @@