Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java =================================================================== diff -u -r0d5b1b50fe6fe0f20f48982e924cc72a2910eb07 -r1dc854b38e29aa1fb3c35c2f931793ef77717866 --- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 0d5b1b50fe6fe0f20f48982e924cc72a2910eb07) +++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 1dc854b38e29aa1fb3c35c2f931793ef77717866) @@ -1348,14 +1348,12 @@ logger.debug("qaContent has been updated for runOffline: " + mcContent); } - - /* + /** + * Part of the tool contract. Removes content and uploaded files from the content repository. + * removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException * - * Will need an update on the core tool signature: reason : when mcContent is null throw an exception - * (non-Javadoc) - * @see org.lamsfoundation.lams.tool.ToolContentManager#removeToolContent(java.lang.Long, boolean) - */ + */ public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException { logger.debug("start of: removeToolContent(Long toolContentId, boolean removeSessionData"); @@ -1372,6 +1370,28 @@ if (mcContent != null) { + logger.debug("start deleting any uploaded file for this content from the content repository"); + Iterator filesIterator=mcContent.getMcAttachments().iterator(); + while (filesIterator.hasNext()) + { + McUploadedFile mcUploadedFile=(McUploadedFile) filesIterator.next(); + logger.debug("iterated mcUploadedFile : " + mcUploadedFile); + String filesUuid=mcUploadedFile.getUuid(); + if ((filesUuid != null) && (filesUuid.length() > 0)) + { + try + { + mcToolContentHandler.deleteFile(new Long(filesUuid)); + } + catch(RepositoryCheckedException e) + { + logger.debug("exception occured deleting files from content repository : " + e); + throw new ToolException("undeletable file in the content repository"); + } + } + } + logger.debug("end deleting any uploaded files for this content."); + Iterator sessionIterator=mcContent.getMcSessions().iterator(); while (sessionIterator.hasNext()) { @@ -1400,9 +1420,8 @@ } } } - logger.debug("removed all existing responses of toolContent with toolContentId:" + - toolContentId); + toolContentId); mcContentDAO.removeMcById(toolContentId); logger.debug("removed qaContent:" + mcContent); }