Index: lams_tool_nb/conf/xdoclet/filter-mappings.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/conf/xdoclet/filter-mappings.xml,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_nb/conf/xdoclet/filter-mappings.xml 16 Nov 2005 00:37:50 -0000 1.1 @@ -0,0 +1,9 @@ + + SystemSessionFilter + /* + + + + hibernateFilter + /* + Index: lams_tool_nb/conf/xdoclet/filters.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/conf/xdoclet/filters.xml,v diff -u -r1.1 -r1.2 --- lams_tool_nb/conf/xdoclet/filters.xml 23 Sep 2005 07:26:45 -0000 1.1 +++ lams_tool_nb/conf/xdoclet/filters.xml 16 Nov 2005 00:37:50 -0000 1.2 @@ -6,4 +6,20 @@ contentFilter /portfolioExport - --> \ No newline at end of file + --> + + + SystemSessionFilter + org.lamsfoundation.lams.web.session.SystemSessionFilter + + + + hibernateFilter + + org.lamsfoundation.lams.util.CustomizedOpenSessionInViewFilter + + + sessionFactoryBeanName + nbSessionFactory + + Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardAttachment.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/Attic/NoticeboardAttachment.java,v diff -u -r1.7 -r1.8 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardAttachment.java 10 Aug 2005 06:49:31 -0000 1.7 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardAttachment.java 16 Nov 2005 00:37:50 -0000 1.8 @@ -25,9 +25,11 @@ package org.lamsfoundation.lams.tool.noticeboard; import java.io.Serializable; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.apache.commons.lang.builder.EqualsBuilder; +import org.apache.commons.lang.builder.HashCodeBuilder; + /** *

This class represents a file that is uploaded to the noticeboard tool. * It is used in the authoring environment, when an author @@ -40,7 +42,9 @@ */ public class NoticeboardAttachment implements Serializable { - /** identifier field */ + private static final long serialVersionUID = -3471513404550541296L; + + /** identifier field */ private Long attachmentId; /** persistent field. Cannot be null */ @@ -184,4 +188,28 @@ { return (getFilename() + "-" + returnFileType()); } + + /** Are two NoticeboardAttachments equal? Checks attachmentId, filename, + * uuid, version id and online/offline status. Does not check the related + * content object. + */ + public boolean equals(Object other) { + if ( (this == other ) ) return true; + if ( !(other instanceof NoticeboardAttachment) ) return false; + NoticeboardAttachment castOther = (NoticeboardAttachment) other; + return new EqualsBuilder() + .append(this.getAttachmentId(), castOther.getAttachmentId()) + .append(this.getFilename(), castOther.getFilename()) + .append(this.getUuid(), castOther.getUuid()) + .append(this.getVersionId(), castOther.getVersionId()) + .append(this.isOnlineFile(), castOther.isOnlineFile()) + .isEquals(); + } + + /** Generate the hashcode for the class. Based on the attachment id only. */ + public int hashCode() { + return new HashCodeBuilder() + .append(getAttachmentId()) + .toHashCode(); + } } 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.17 -r1.18 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardConstants.java 9 Nov 2005 22:03:49 -0000 1.17 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/NoticeboardConstants.java 16 Nov 2005 00:37:50 -0000 1.18 @@ -55,10 +55,6 @@ public static final String DISPLAY_MESSAGE = "displayMessage"; public static final String DISPLAY_LEARNER_CONTENT = "displayLearnerContent"; - public static final String TOOL_ACCESS_MODE_LEARNER = "learner"; - public static final String TOOL_ACCESS_MODE_AUTHOR = "author"; - public static final String TOOL_ACCESS_MODE_TEACHER = "teacher"; - public static final String MONITOR_PAGE = "monitorPage"; // ------------------------------ @@ -87,19 +83,20 @@ public static final String EXPORT_PORTFOLIO = "exportPortfolio"; //used in authoring - public static final String TOOL_CONTENT_ID = "toolContentId"; //request + session variable + public static final String TOOL_CONTENT_ID = "toolContentID"; //request + session variable public static final String RICH_TEXT_TITLE = "richTextTitle"; public static final String RICH_TEXT_CONTENT = "richTextContent"; public static final String RICH_TEXT_ONLINE_INSTRN = "richTextOnlineInstructions"; public static final String RICH_TEXT_OFFLINE_INSTRN = "richTextOfflineInstructions"; public static final String ATTACHMENT_LIST = "attachmentList"; + public static final String DELETED_ATTACHMENT_LIST = "deletedAttachmentList"; public static final String READ_ONLY_MODE = "readOnlyMode"; - public static final String USER_ID = "userId"; - public static final String TOOL_SESSION_ID = "toolSessionId"; + public static final String USER_ID = "userID"; + public static final String TOOL_SESSION_ID = "toolSessionID"; public static final String UUID = "uuid"; // --------------------------------------------------------------------------- @@ -137,5 +134,5 @@ public static final String ERROR_NBAPPLICATION = "error.exception.NbApplication"; public static final String ERROR_MANDATORY="error.mandatoryField"; public static final String ERR_MISSING_PARAM = "error.missingParam"; - + public static final String ERROR_FILE_UPLOAD_CONTENT_REPOSITORY = "error.contentrepository"; } 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.11 -r1.12 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java 26 Aug 2005 02:42:12 -0000 1.11 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java 16 Nov 2005 00:37:50 -0000 1.12 @@ -21,11 +21,12 @@ package org.lamsfoundation.lams.tool.noticeboard.service; +import java.util.List; + +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; -import java.util.List; /** @@ -59,16 +60,8 @@ public NoticeboardContent retrieveNoticeboard(Long nbContentId); - /** - *

Update the given persistent instance of NoticeboardContent.

- * - * @param nbContent The instance of NoticeboardContent to persist. - */ - public void updateNoticeboard(NoticeboardContent nbContent); - - /** - *

Persist the given persistent instance of NoticeboardContent.

+ *

Persist/Update the given persistent instance of NoticeboardContent.

* * @param nbContent The instance of NoticeboardContent to persist. */ @@ -297,22 +290,24 @@ /** *

Saves (persists) or update the NoticeboardAttachment object in the * database.

+ * @param content The overall noticeboard content object to which the attachment is to be added * @param attachment The instance of NoticeboardAttachment to save */ - public void saveAttachment(NoticeboardAttachment attachment); + public void saveAttachment(NoticeboardContent content, NoticeboardAttachment attachment); /** * Removes the NoticeboardAttachment object from the database. + * @param content The overall noticeboard content object to which the attachment is to be added * @param attachment The instance of NoticeboardAttachment to delete. */ - public void removeAttachment(NoticeboardAttachment attachment); + public void removeAttachment(NoticeboardContent content, NoticeboardAttachment attachment); - /** + /* Not used? * Removes the NoticeboardAttachment object from the database * with uuid uuid * @param uuid The uuid of the file - */ public void removeAttachmentByUuid(Long uuid); + */ /** * 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.12 -r1.13 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 26 Aug 2005 02:42:44 -0000 1.12 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 16 Nov 2005 00:37:50 -0000 1.13 @@ -22,39 +22,33 @@ package org.lamsfoundation.lams.tool.noticeboard.service; import java.util.Date; -import java.util.List; import java.util.Iterator; +import java.util.List; import org.apache.log4j.Logger; +import org.lamsfoundation.lams.learning.service.ILearnerService; +import org.lamsfoundation.lams.tool.ToolContentManager; +import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; +import org.lamsfoundation.lams.tool.ToolSessionManager; +import org.lamsfoundation.lams.tool.exception.DataMissingException; +import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; +import org.lamsfoundation.lams.tool.exception.ToolException; +import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardSession; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardUser; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; +import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardAttachmentDAO; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardContentDAO; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardSessionDAO; import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardUserDAO; -import org.lamsfoundation.lams.tool.noticeboard.dao.INoticeboardAttachmentDAO; - +import org.lamsfoundation.lams.tool.service.ILamsToolService; +import org.lamsfoundation.lams.usermanagement.User; import org.springframework.dao.DataAccessException; -import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; -import org.lamsfoundation.lams.tool.ToolContentManager; -import org.lamsfoundation.lams.tool.ToolSessionManager; -import org.lamsfoundation.lams.tool.exception.DataMissingException; -import org.lamsfoundation.lams.tool.exception.ToolException; -import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; -import org.lamsfoundation.lams.tool.ToolSessionExportOutputData; - -import org.lamsfoundation.lams.usermanagement.User; - -import org.lamsfoundation.lams.learning.service.ILearnerService; -import org.lamsfoundation.lams.tool.service.ILamsToolService; - - - /** * An implementation of the NoticeboardService interface. * @@ -76,7 +70,6 @@ private NoticeboardUser nbUser; private INoticeboardUserDAO nbUserDAO=null; - private NoticeboardAttachment nbAttachment; private INoticeboardAttachmentDAO nbAttachmentDAO = null; @@ -145,31 +138,17 @@ /** - * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#updateNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) - */ - public void updateNoticeboard(NoticeboardContent nbContent) - { - try - { - nbContentDAO.updateNbContent(nbContent); - } - catch (DataAccessException e) - { - throw new NbApplicationException("An exception has occured while trying to update a noticeboard content object: " - + e.getMessage(), - e); - } - - } - - /** * @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveNoticeboard(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ public void saveNoticeboard(NoticeboardContent nbContent) { try { - nbContentDAO.saveNbContent(nbContent); + if ( nbContent.getUid() == null ) { + nbContentDAO.saveNbContent(nbContent); + } else { + nbContentDAO.updateNbContent(nbContent); + } } catch (DataAccessException e) { @@ -727,11 +706,13 @@ } /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) */ - public void saveAttachment(NoticeboardAttachment attachment) + public void saveAttachment(NoticeboardContent content, NoticeboardAttachment attachment) { try { - nbAttachmentDAO.saveAttachment(attachment); + content.getNbAttachments().add(attachment); + attachment.setNbContent(content); + saveNoticeboard(content); } catch (DataAccessException e) { @@ -741,11 +722,13 @@ } /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) */ - public void removeAttachment(NoticeboardAttachment attachment) + public void removeAttachment(NoticeboardContent content, NoticeboardAttachment attachment) { try { - nbAttachmentDAO.removeAttachment(attachment); + attachment.setNbContent(null); + content.getNbAttachments().remove(attachment); + saveNoticeboard(content); } catch (DataAccessException e) { @@ -754,7 +737,8 @@ } } - /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeAttachmentByUuid(java.lang.Long) */ + /* Not used? + @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeAttachmentByUuid(java.lang.Long) public void removeAttachmentByUuid(Long uuid) { if (uuid == null) @@ -773,10 +757,10 @@ + e.getMessage(), e); } } + */ - /* ===============Methods implemented from ToolContentManager =============== */ /** @see org.lamsfoundation.lams.tool.ToolContentManager#copyToolContent(java.lang.Long, java.lang.Long)*/ @@ -826,7 +810,7 @@ nbContent.setDefineLater(true); //nbContent.setContentInUse(false); //if define later is set to true, then contentInUse flag should be false - updateNoticeboard(nbContent); + saveNoticeboard(nbContent); } @@ -836,7 +820,7 @@ NoticeboardContent nbContent = getAndCheckIDandObject(toolContentId); nbContent.setForceOffline(true); - updateNoticeboard(nbContent); + saveNoticeboard(nbContent); } /** @see org.lamsfoundation.lams.tool.ToolContentManager#removeToolContent(java.lang.Long)*/ Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbWebUtil.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbWebUtil.java,v diff -u -r1.5 -r1.6 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbWebUtil.java 10 Aug 2005 06:52:34 -0000 1.5 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbWebUtil.java 16 Nov 2005 00:37:50 -0000 1.6 @@ -27,14 +27,15 @@ package org.lamsfoundation.lams.tool.noticeboard.util; import java.util.ArrayList; -import java.util.Collection; import java.util.List; -import java.util.Map; + import javax.servlet.http.HttpServletRequest; import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; /** * This Web Utility class contains helper methods used in the Action Servlets @@ -63,6 +64,7 @@ { request.getSession().removeAttribute(NoticeboardConstants.TOOL_CONTENT_ID); request.getSession().removeAttribute(NoticeboardConstants.ATTACHMENT_LIST); + request.getSession().removeAttribute(NoticeboardConstants.DELETED_ATTACHMENT_LIST); } public static void cleanLearnerSession(HttpServletRequest request) @@ -79,6 +81,9 @@ request.getSession().removeAttribute(NoticeboardConstants.OFFLINE_INSTRUCTIONS); request.getSession().removeAttribute(NoticeboardConstants.ONLINE_INSTRUCTIONS); request.getSession().removeAttribute(NoticeboardConstants.ATTACHMENT_LIST); + // deleted attachments probably isn't used in monitoring, but included + // here to keep it consistent with authoring. + request.getSession().removeAttribute(NoticeboardConstants.DELETED_ATTACHMENT_LIST); } @@ -126,24 +131,63 @@ } /** - *

This method takes in a Map as a parameter and converts it - * into a Collections view of the values of this map. A new - * ArrayList is formed from this Collection of values and stored in - * the session scope variable attachmentList (represented by NoticeboardConstants.ATTACHMENT_LIST)

- * *

This method is used in authoring and monitoring to display the list of files that have been uploaded. - * They key for this map is the filename-fileType where fileType is either "online" or "offline" - * and the value that maps to this key, is an NoticeboardAttachment object.

+ * Contents of the collections are NoticeboardAttachments. The current files are included in the attachmentList, + * files that the user has nominated to delete are in the deletedAttachementList.

* + *

If the input collections are null, then the session variables are not modified. This + * is particularly useful for the deleted files.

+ * * @param request the HttpServletRequest which is used to obtain the HttpSession - * @param map + * @param attachmentList + * @param deletedAttachmentList */ - public static void addUploadsToSession(HttpServletRequest request, Map map) + public static void addUploadsToSession(HttpServletRequest request, List attachmentList, List deletedAttachmentList) { - Collection entries = map.values(); - List attachmentList = new ArrayList(entries); - request.getSession().setAttribute(NoticeboardConstants.ATTACHMENT_LIST, attachmentList); + if ( attachmentList != null ) { + request.getSession().setAttribute(NoticeboardConstants.ATTACHMENT_LIST, attachmentList); + } + + // deleted will be empty most of the time + if ( deletedAttachmentList != null ) { + request.getSession().setAttribute(NoticeboardConstants.DELETED_ATTACHMENT_LIST, deletedAttachmentList); + } + } + /** Setup the map containing the files that have been uploaded for this particular tool content id. + * If NoticeboardContent content exists, set nb=null and an empty list will be created. + * + * @param nbService + * @param attachmentMap + * @param nb + * @return the updated attachmentMap + */ + public static List setupAttachmentList(INoticeboardService nbService, List attachmentList, NoticeboardContent nb) { + + List updatedList = attachmentList != null ? attachmentList : new ArrayList(); + + if ( nbService!=null && nb!=null ) { + List attachmentIdList = nbService.getAttachmentIdsFromContent(nb); + for (int i=0; i {0} \ No newline at end of file +error.exception.NbApplication=An internal error has occured with the Noticeboard Tool. If reporting this error, please report:
{0} +error.contentrepository=An error has occurred when saving/deleting instruction file {0}. The files may not be saved correctly. 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.15 -r1.16 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 9 Nov 2005 22:03:49 -0000 1.15 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 16 Nov 2005 00:37:49 -0000 1.16 @@ -25,41 +25,41 @@ */ package org.lamsfoundation.lams.tool.noticeboard.web; -import java.util.Date; +import java.io.FileNotFoundException; +import java.io.IOException; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.FileNotFoundException; -import java.io.IOException; -import org.apache.log4j.Logger; -import org.lamsfoundation.lams.web.action.LamsLookupDispatchAction; +import javax.servlet.http.HttpSession; - +import org.apache.log4j.Logger; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; - -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; -import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; -import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; -import org.lamsfoundation.lams.tool.noticeboard.util.NbToolContentHandler; -import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; -import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; import org.apache.struts.upload.FormFile; import org.apache.struts.util.MessageResources; -import org.lamsfoundation.lams.util.WebUtil; - -//import org.lamsfoundation.lams.contentrepository.CrNodeVersionProperty; import org.lamsfoundation.lams.contentrepository.InvalidParameterException; import org.lamsfoundation.lams.contentrepository.NodeKey; import org.lamsfoundation.lams.contentrepository.RepositoryCheckedException; +import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; +import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; +import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.util.NbToolContentHandler; +import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsLookupDispatchAction; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -123,7 +123,6 @@ return map; } - public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NbApplicationException { MessageResources resources = getResources(request); @@ -156,7 +155,7 @@ * Retrieve the Service */ INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); - Map attachmentMap = nbForm.getAttachments(); + List attachmentList = (List) request.getSession().getAttribute(NoticeboardConstants.ATTACHMENT_LIST); if (!contentExists(nbService, contentId)) { @@ -166,32 +165,21 @@ // logger.debug("Default tool content id is " + defaultToolContentId); NoticeboardContent nb = nbService.retrieveNoticeboard(defaultToolContentId); - /** TODO: add a check to see if object is null */ if (nb==null) { String error= "There is data missing in the database"; logger.error(error); throw new NbApplicationException(error); } - //create a new noticeboard object and prefill with default content, save to database - NoticeboardContent nbContentNew = new NoticeboardContent(contentId, - nb.getTitle(), - nb.getContent(), - nb.getOnlineInstructions(), - nb.getOfflineInstructions(), - new Date(System.currentTimeMillis())); - - nbContentNew = setTrueIfDefineLaterIsSet(nbForm, nbContentNew); - - //save new tool content into db - nbService.saveNoticeboard(nbContentNew); - //initialise the values in the form, so the values will be shown in the jsp - nbForm.populateFormWithNbContentValues(nbContentNew); + nbForm.setToolContentID(contentId.toString()); + nbForm.setTitle(nb.getTitle()); + nbForm.setContent(nb.getContent()); + nbForm.setOnlineInstructions(nb.getOnlineInstructions()); + nbForm.setOfflineInstructions(nb.getOfflineInstructions()); - - + attachmentList = NbWebUtil.setupAttachmentList(nbService,null,null); } else //content already exists on the database @@ -209,7 +197,7 @@ * So that users cannot start using the content while the staff member is editing the content */ nbForm.populateFormWithNbContentValues(nb); nb = setTrueIfDefineLaterIsSet(nbForm, nb); - nbService.updateNoticeboard(nb); + nbService.saveNoticeboard(nb); /** TODO: setup values in the instructions map */ @@ -226,24 +214,13 @@ } //Setup the map containing the files that have been uploaded for this particular tool content id - - List attachmentIdList = nbService.getAttachmentIdsFromContent(nb); - for (int i=0; itoolContentId, then this method will - * return true, to indicate that the file already exists in the database. - * Otherwise false is returned. - * @param filename The filename of the attachment to check - * @param isOnlineFile A boolean to indicate whether it is an online File. 1 indicates an online file. The value 0 indicates an offline file. - * @return - */ - private boolean fileExists(Long toolContentId, NoticeboardAttachment fileFromDatabase, boolean isFileUploadedAnOnlineFile) - { - - if (fileFromDatabase == null) - { - return false; - } - else - { - /** - * true && true = true <-- both files are both online files - * true && false = false <-- the files are different types - * false && true = false <-- the files are different types - * false && false = true <-- both files are offline files - */ - if (fileFromDatabase.isOnlineFile() && isFileUploadedAnOnlineFile && fileFromDatabase.getNbContent().getNbContentId().equals(toolContentId)) - { - return true; - } - else - return false; - } - } - - } 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.11 -r1.12 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java 31 Oct 2005 05:34:59 -0000 1.11 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringForm.java 16 Nov 2005 00:37:49 -0000 1.12 @@ -30,23 +30,16 @@ package org.lamsfoundation.lams.tool.noticeboard.web; import java.util.Date; -import java.util.Map; -import java.util.HashMap; +import javax.servlet.http.HttpServletRequest; + import org.apache.log4j.Logger; -import org.apache.struts.Globals; -import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionErrors; -import org.apache.struts.action.ActionMessage; - +import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; -import org.apache.struts.util.MessageResources; -import javax.servlet.http.HttpServletRequest; - -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; - - +import org.apache.struts.action.ActionMessage; import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.util.UploadFileUtil; @@ -77,6 +70,8 @@ public class NbAuthoringForm extends ActionForm { + private static final long serialVersionUID = -8425012664714570196L; + static Logger logger = Logger.getLogger(NbAuthoringForm.class.getName()); private String title; @@ -90,26 +85,7 @@ private FormFile onlineFile; private FormFile offlineFile; - private Map attachments = new HashMap(); - - - /** - * @return Returns the attachments. - */ - public Map getAttachments() { - if (attachments == null) - { - return new HashMap(); - } - return attachments; - } - /** - * @param attachments The attachments to set. - */ - public void setAttachments(Map attachments) { - this.attachments = attachments; - } - + /** * @return Returns the offlineFile. */ @@ -268,9 +244,6 @@ //check the tool content id //check the title and instructions - MessageResources resources = - (MessageResources) request.getAttribute(Globals.MESSAGES_KEY); - float maxFileSize = UploadFileUtil.getMaxFileSize(); if (this.offlineFile != null && offlineFile.getFileSize()!= 0) @@ -302,10 +275,5 @@ } - private boolean isEmpty(String str) { - return str == null || str.trim().length() == 0 ; - } - - } Index: lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringStarterAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/Attic/NbAuthoringStarterAction.java,v diff -u -r1.13 -r1.14 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringStarterAction.java 31 Oct 2005 05:34:59 -0000 1.13 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringStarterAction.java 16 Nov 2005 00:37:49 -0000 1.14 @@ -27,37 +27,26 @@ import java.util.Date; import java.util.List; -import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; - -//import org.apache.struts.action.Action; -import org.lamsfoundation.lams.web.action.LamsAction; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; - +import org.apache.struts.action.ActionMessage; +import org.apache.struts.action.ActionMessages; +import org.apache.struts.util.MessageResources; +import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; - +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; +import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; +import org.lamsfoundation.lams.web.action.LamsAction; -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; -import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; -import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; - -import org.apache.struts.action.ActionMessages; -import org.apache.struts.action.ActionMessage; -import org.apache.struts.util.MessageResources; - -import org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment; - - /** * Creation Date: 19-05-05 * @@ -153,7 +142,7 @@ * Retrieve the Service */ INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); - Map attachmentMap = nbForm.getAttachments(); + List attachmentList = (List) request.getSession().getAttribute(NoticeboardConstants.ATTACHMENT_LIST); if (!contentExists(nbService, contentId)) { @@ -206,7 +195,7 @@ * So that users cannot start using the content while the staff member is editing the content */ nbForm.populateFormWithNbContentValues(nb); nb = setTrueIfDefineLaterIsSet(nbForm, nb); - nbService.updateNoticeboard(nb); + nbService.saveNoticeboard(nb); /** TODO: setup values in the instructions map */ @@ -222,27 +211,15 @@ } - //Setup the map containing the files that have been uploaded for this particular tool content id - - List attachmentIdList = nbService.getAttachmentIdsFromContent(nb); - for (int i=0; i Noticeboard tool + + + css/tool_custom.css" rel="stylesheet" type="text/css"> -