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 @@
+
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 uuiduuid
* @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