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.6 -r1.7 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java 21 Jul 2005 04:36:56 -0000 1.6 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/INoticeboardService.java 29 Jul 2005 04:29:22 -0000 1.7 @@ -24,6 +24,7 @@ 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; @@ -248,4 +249,43 @@ */ public int calculateTotalNumberOfUsers(Long toolContentId); + //=================================================================== + // NoticeboardAttachment access methods + //=================================================================== + + /** + *

Retrieve an instance of NoticeboardAttachment with the given + * attachment id attachmentId

+ * @param attachmentId The id for the attachment file + * @return an instance of NoticeboardAttachment + */ + public NoticeboardAttachment retrieveAttachment(Long attachmentId); + + /** + *

Retrieve the file attachment with the given uuid

+ * @param uuid The unique identifier for the file, corresponds to the uuid for the file stored in content repository + * @return an instance of NoticeboardAttachment + */ + public NoticeboardAttachment retrieveAttachmentByUuid(Long uuid); + + /** + *

Retrieve the list of attachment ids with the given instance of NoticeboardContent

+ * @param nbContent The given instance of NoticeboardContent + * @return List. the list of attachment ids (java.lang.Long) + */ + public List getAttachmentIdsFromContent(NoticeboardContent nbContent); + + /** + *

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

+ * @param attachment The instance of NoticeboardAttachment to save + */ + public void saveAttachment(NoticeboardAttachment attachment); + + /** + * Removes the NoticeboardAttachment object from the database. + * @param attachment The instance of NoticeboardAttachment to delete. + */ + public void removeAttachment(NoticeboardAttachment attachment); + } 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.7 -r1.8 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 22 Jul 2005 06:59:42 -0000 1.7 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/service/NoticeboardServicePOJO.java 29 Jul 2005 04:29:22 -0000 1.8 @@ -30,9 +30,11 @@ 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.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.springframework.dao.DataAccessException; import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; @@ -69,6 +71,9 @@ private NoticeboardUser nbUser; private INoticeboardUserDAO nbUserDAO=null; + private NoticeboardAttachment nbAttachment; + private INoticeboardAttachmentDAO nbAttachmentDAO = null; + private static Logger log = Logger.getLogger(NoticeboardServicePOJO.class); @@ -619,6 +624,99 @@ return totalNumberOfUsers; } + /* ============================================================================== + * Methods for access to NoticeboardUser objects + * ============================================================================== + */ + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachment(java.lang.Long) */ + public NoticeboardAttachment retrieveAttachment(Long attachmentId) + { + if (attachmentId == null) + { + String error = "Unable to continue. The attachment id is missing"; + log.error(error); + throw new NbApplicationException(error); + } + + try + { + return nbAttachmentDAO.retrieveAttachment(attachmentId); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve the attachment " + + e.getMessage(), e); + } + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#retrieveAttachmentByUuid(java.lang.Long) */ + public NoticeboardAttachment retrieveAttachmentByUuid(Long uuid) + { + if (uuid == null) + { + String error = "Unable to continue. The uuid is missing"; + log.error(error); + throw new NbApplicationException(error); + } + try + { + return nbAttachmentDAO.retrieveAttachmentByUuid(uuid); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve the attachment " + + e.getMessage(), e); + } + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#getAttachmentIdsFromContent(org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent) */ + public List getAttachmentIdsFromContent(NoticeboardContent nbContent) + { + try + { + return nbAttachmentDAO.getAttachmentIdsFromContent(nbContent); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to retrieve the list of attachment ids " + + e.getMessage(), e); + } + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#saveAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) */ + public void saveAttachment(NoticeboardAttachment attachment) + { + try + { + nbAttachmentDAO.saveAttachment(attachment); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to save the attachment " + + e.getMessage(), e); + } + } + + /** @see org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService#removeAttachment(org.lamsfoundation.lams.tool.noticeboard.NoticeboardAttachment) */ + public void removeAttachment(NoticeboardAttachment attachment) + { + try + { + nbAttachmentDAO.removeAttachment(attachment); + } + catch (DataAccessException e) + { + throw new NbApplicationException("EXCEPTION: An exception has occurred while trying to remove this attachment" + + e.getMessage(), e); + } + } + + + + + + /* ===============Methods implemented from ToolContentManager =============== */ /** @see org.lamsfoundation.lams.tool.ToolContentManager#copyToolContent(java.lang.Long, java.lang.Long)*/ @@ -856,4 +954,14 @@ { this.nbUserDAO = nbUserDAO; } + + + + public INoticeboardAttachmentDAO getNbAttachmentDAO() { + return nbAttachmentDAO; + } + + public void setNbAttachmentDAO(INoticeboardAttachmentDAO nbAttachmentDAO) { + this.nbAttachmentDAO = nbAttachmentDAO; + } }