This Action class process any actions that are made by the user.
- *
- *
When the following buttons are pressed:
- * NoticeboardConstants.BUTTON_BASIC, NoticeboardConstants.BUTTON_ADVANCED,
- * NoticeboardConstants.BUTTON_INSTRUCTIONS or NoticeboardConstants.BUTTON_DONE,
- * they switch between the tabs, but before doing so, they copy the values
- * in the form (only if they are not null) and place them in the
- * equivalent formbean properties (session scope). This is done so because the form
- * is spread across two pages (basic and instructions, in Noticeboard tool, there is
- * no Advanced page). It might be strange that all buttons forward to the same path,
- * but the formbean property "method" keeps a track of what button was pressed.
- * So when control returns to the jsp, it will determine the value of method and
- * show the appropriate page.
+ *
This class is a simple combination of NbAuthoringStarterAction and NbAuthoringAction.
+ * It has been created for the purpose of supporting the new authoring page which is done using
+ * DHTML.
*
- *
The button NoticeboardConstants.BUTTON_UPLOAD triggers an upload and will
- * upload either a file of type "ONLINE" or "OFFLINE", to the content repository
- * and will save the file details (filename, toolcontent id, uuid, and filetype).
- * It will also conduct checks
- * to see whether the same file (and same type) has been uploaded or not.
- * If the same file has been uploaded (to the same noticeboard instance, ie. same
- * tool content id) then, it will delete the file from the content respository
- * and delete that particular entry in the table, and then it the new version
- * will be uploaded to the content repository and a new entry will be saved into
- * the database. It then updates the attachment map that was initially setup
- * by NbAuthoringStarterAction.
+ *
The unspecified method, is the same as the execute method for NbAuthoringStarterAction.
+ * It will get called when the method parameter is not specified (that is on first entry
+ * into the authoring environment).
*
- *
The button NoticeboardConstants.LINK_DELETE will trigger the deleteAttachment
- * action which will delete a file from the content repository, and the entry from
- * the attachment table.
- *
- *
The save method persist the values of the formbean properties
- * title, instructions, onlineInstructions and offlineInstructions to
- * the database
- *
- *
+ *
The save, upload and delete method is the same as that of NbAuthoringAction, to see its explanation,
+ * please see org.lamsfoundation.lams.tool.noticeboard.web.NbAuthoringAction
+ *
* ----------------XDoclet Tags--------------------
*
* @struts:action path="/authoring" name="NbAuthoringForm" scope="session"
* type="org.lamsfoundation.lams.tool.noticeboard.web.NbAuthoringAction"
- * parameter="method" validate="true" input=".authoringContent"
+ * parameter="method" validate="true" input="/author_page.jsp"
*
* @struts.action-exception key="error.exception.NbApplication" scope="request"
* type="org.lamsfoundation.lams.tool.noticeboard.NbApplicationException"
@@ -108,14 +92,16 @@
* path=".error"
* handler="org.lamsfoundation.lams.tool.noticeboard.web.CustomStrutsExceptionHandler"
*
- * @struts:action-forward name="authoringContent" path=".authoringContent"
+ * @struts:action-forward name="authoringContent" path="/author_page.jsp"
+ * @struts:action-forward name="displayMessage" path=".message"
*
* ----------------XDoclet Tags--------------------
*/
public class NbAuthoringAction extends LamsLookupDispatchAction {
-
static Logger logger = Logger.getLogger(NbAuthoringAction.class.getName());
+ public final static String FORM="NbAuthoringForm";
+
private NbToolContentHandler toolContentHandler;
private NbToolContentHandler getToolContentHandler()
@@ -127,364 +113,455 @@
return toolContentHandler;
}
-
protected Map getKeyMethodMap()
{
Map map = new HashMap();
- map.put(NoticeboardConstants.BUTTON_BASIC, "basic" );
- map.put(NoticeboardConstants.BUTTON_ADVANCED, "advanced" );
- map.put(NoticeboardConstants.BUTTON_INSTRUCTIONS, "instructions");
- map.put(NoticeboardConstants.BUTTON_DONE, "done");
map.put(NoticeboardConstants.BUTTON_SAVE, "save");
map.put(NoticeboardConstants.BUTTON_UPLOAD, "upload");
map.put(NoticeboardConstants.LINK_DELETE, "deleteAttachment");
return map;
}
-
- /**
- *
- */
- public ActionForward unspecified(
- ActionMapping mapping,
- ActionForm form,
- HttpServletRequest request,
- HttpServletResponse response)
- {
- NbAuthoringForm nbForm = (NbAuthoringForm)form;
- copyAuthoringFormValuesIntoFormBean(request, nbForm);
- return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
- }
-
- /**
- * Forwards to the basic page.
- */
- public ActionForward basic(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
+
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NbApplicationException {
+
+ MessageResources resources = getResources(request);
+
+ //to ensure that we are working with a new form, not one from previous session
+ NbAuthoringForm nbForm = new NbAuthoringForm();
+ NbWebUtil.cleanAuthoringSession(request);
- NbAuthoringForm nbForm = (NbAuthoringForm)form;
- copyAuthoringFormValuesIntoFormBean(request, nbForm);
- // return mapping.findForward(NoticeboardConstants.BASIC_PAGE);
- return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
- }
-
- /**
- * Forwards to the advanced page.
- */
-
- public ActionForward advanced(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
- return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
- }
-
- /**
- * Forwards to the instructions page.
- */
-
- public ActionForward instructions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
- NbAuthoringForm nbForm = (NbAuthoringForm)form;
- copyAuthoringFormValuesIntoFormBean(request, nbForm);
-
- return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
- }
-
- /**
- * Online/Offline instructions entered, form values saved and forward to the basic page.
- */
-
- public ActionForward done(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
- NbAuthoringForm nbForm = (NbAuthoringForm)form;
- copyAuthoringFormValuesIntoFormBean(request, nbForm);
-
- return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
- }
-
- /**
- * Persist the values of the noticeboard content (title, content, online and offline instructions)
- * into the database.
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws NbApplicationException
- */
- public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NbApplicationException {
+ Long contentId = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.TOOL_CONTENT_ID));
- NbAuthoringForm nbForm = (NbAuthoringForm)form;
- copyAuthoringFormValuesIntoFormBean(request, nbForm);
-
- INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext());
- String idAsString = nbForm.getToolContentID();
- if (idAsString == null)
- {
- String error = "Unable to continue. Tool content id missing";
+ if(contentId == null)
+ {
+ //String error = "Tool content id missing. Unable to continue.";
+ String error = resources.getMessage(NoticeboardConstants.ERR_MISSING_PARAM, "Tool Content Id");
logger.error(error);
throw new NbApplicationException(error);
}
- Long content_id = NbWebUtil.convertToLong(nbForm.getToolContentID());
+ nbForm.setToolContentID(contentId.toString());
- //throws exception if the content id does not exist
- checkContentId(content_id);
+ /* if there is a defineLater request parameter, set the form value
+ * If a defineLater request parameter is not present, then it is just set to null.
+ * This is used in the basic screen, if defineLater is set, then in the basic page,
+ * the three tabs {Basic, Advanced, Instructions} are not visible.
+ */
+ nbForm.setDefineLater((String)request.getParameter(NoticeboardConstants.DEFINE_LATER));
+
+ request.getSession().setAttribute(NoticeboardConstants.TOOL_CONTENT_ID, contentId);
+
+ /*
+ * Retrieve the Service
+ */
+ INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext());
+ Map attachmentMap = nbForm.getAttachments();
- NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id);
- nbForm.copyValuesIntoNbContent(nbContent);
- /* Author has finished editing the content and mark the defineLater flag to false */
- nbContent.setDefineLater(false);
- nbService.updateNoticeboard(nbContent);
+ if (!contentExists(nbService, contentId))
+ {
+ // Pre-fill the form with the default content
+ //NoticeboardContent nb = nbService.retrieveNoticeboard(NoticeboardConstants.DEFAULT_CONTENT_ID);
+ Long defaultToolContentId = nbService.getToolDefaultContentIdBySignature(NoticeboardConstants.TOOL_SIGNATURE);
+ // logger.debug("Default tool content id is " + defaultToolContentId);
+ NoticeboardContent nb = nbService.retrieveNoticeboard(defaultToolContentId);
- return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
- }
-
- /**
- * This method will either upload an online instructions file or an offline instructions file.
- * It will upload an online file if the bean property onlineFile is not null and similarly,
- * will upload an offline file if the bean property offlineFile is not null.
- * By using the term "upload", we are saving the file information on the local database (?)
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws NbApplicationException
- */
- public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
- throws InvalidParameterException, FileNotFoundException, RepositoryCheckedException, IOException, NbApplicationException {
-
-
- //set up the values in the map
- //call the uploadFile method from toolContentHandler
- NbAuthoringForm nbForm = (NbAuthoringForm)form;
- copyAuthoringFormValuesIntoFormBean(request, nbForm);
- FormFile theFile;
- INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext());
+ /** 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);
+ }
- Long content_id = NbWebUtil.convertToLong(nbForm.getToolContentID());
- //throws exception if the content id does not exist
- checkContentId(content_id);
- NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id);
-
- //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
+ //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()));
- if ((nbForm.getOnlineFile() != null && (nbForm.getOnlineFile().getFileName().trim().length() != 0)) ||
- (nbForm.getOfflineFile() != null && (nbForm.getOfflineFile().getFileName().trim().length() != 0)))
+ 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);
+
+
+
+
+ }
+ else //content already exists on the database
+ {
+ //get the values from the database
+ NoticeboardContent nb = nbService.retrieveNoticeboard(contentId);
+
+ /* If retrieving existing content, check whether the contentInUse flag is set, if set, the
+ * author is not allowed to edit content
+ */
+
+ if (NbWebUtil.isContentEditable(nb))
{
- boolean isOnlineFile = ((nbForm.getOnlineFile() != null && (nbForm.getOnlineFile().getFileName().trim().length() != 0)) ? true: false );
- theFile = (isOnlineFile ? nbForm.getOnlineFile() : nbForm.getOfflineFile());
- String fileType = isOnlineFile ? NoticeboardAttachment.TYPE_ONLINE : NoticeboardAttachment.TYPE_OFFLINE;
-
- //check to see if FileExists
- NoticeboardAttachment file = nbService.retrieveAttachmentByFilename(theFile.getFileName());
-
-
- try
- {
-
- if (fileExists(content_id, file, isOnlineFile))
- {
- /**
- * The same file belonging to the same toolcontent id already exists.
- * The old version of this file is deleted from the content repository
- * and the new one is saved in the content repository.
- *
- * The entry in the database is then updated with the new uuid and version
- */
- getToolContentHandler().deleteFile(file.getUuid());
-
- nbService.removeAttachment(file);
-
- /* NodeKey node = getToolContentHandler().uploadFile(theFile.getInputStream(), theFile.getFileName(),
- theFile.getContentType(), fileType);
-
- file.setUuid(node.getUuid()); //only need to update the uuid, the rest of the info is the same
- file.setVersionId(node.getVersion());
- nbService.saveAttachment(file); */
-
- }
- /**
- * This is a new file and so is saved to the content repository.
- *
- * A new entry is added to the database.
- */
- NodeKey node = getToolContentHandler().uploadFile(theFile.getInputStream(), theFile.getFileName(),
- theFile.getContentType(), fileType);
- file = new NoticeboardAttachment();
- file.setFilename(theFile.getFileName());
- file.setOnlineFile(isOnlineFile);
- file.setNbContent(nbContent);
- file.setUuid(node.getUuid());
- file.setVersionId(node.getVersion()); /** TODO: change versionId to version */
- nbService.saveAttachment(file);
-
-
- String keyName = file.returnKeyName();
-
- //add the files to the map
- Map attachmentMap = nbForm.getAttachments();
- if (!attachmentMap.containsKey(keyName))
- {
- attachmentMap.put(keyName, file);
- }
-
- NbWebUtil.addUploadsToSession(request, attachmentMap);
- //reset the fields so that more files can be uploaded
- nbForm.setOfflineFile(null);
- nbForm.setOnlineFile(null);
- }
- catch (FileNotFoundException e) {
- logger.error("Unable to uploadfile",e);
- throw new NbApplicationException("Unable to upload file, exception was "+e.getMessage());
- } catch (IOException e) {
- logger.error("Unable to uploadfile",e);
- throw new NbApplicationException("Unable to upload file, exception was "+e.getMessage());
- } catch (RepositoryCheckedException e) {
- logger.error("Unable to uploadfile",e);
- throw new NbApplicationException("Unable to upload file, exception was "+e.getMessage());
- }
+ /* Define later set to true when the edit activity tab is brought up
+ * 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);
+
+ /** TODO: setup values in the instructions map */
+
}
-
- nbForm.setMethod(NoticeboardConstants.INSTRUCTIONS);
+ else
+ {
+ //The contentInUse flag is set and a user has already reached this activity.
+ saveMessages(request, null); //ensure there are no existing messages
+ ActionMessages message = new ActionMessages();
+ message.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("message.contentInUseSet"));
+ saveMessages(request, message);
+ return mapping.findForward(NoticeboardConstants.DISPLAY_MESSAGE);
+
+ }
- return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
- }
+ //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 to check
- */
- private void checkContentId(Long contentId)
- {
- if (contentId == null)
- {
- String error = "Unable to continue. Tool content id missing.";
-
- throw new NbApplicationException(error);
- }
- }
-
- /**
- * This method copies the values of the request parameters richTextOnlineInstructions
- * richTextOfflineInstructionsrichTextContent into the form properties
- * onlineInstructions, offlineInstructions and content respectively.
- * If a null value is returned for the request parameter, the form value is not modified.
- * The request parameters are set as optional because the form spans amongst two pages.
- *
- * @param request HttpServlet request
- * @param form The ActionForm class containing data submitted by the forms.
- */
- private void copyAuthoringFormValuesIntoFormBean(HttpServletRequest request, NbAuthoringForm form)
- {
- String onlineInstruction = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_ONLINE_INSTRN, true);
- String offlineInstruction = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_OFFLINE_INSTRN, true);
- String content = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_CONTENT, true);
- String title = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_TITLE, true);
+
+ public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws NbApplicationException {
+
+ NbAuthoringForm nbForm = (NbAuthoringForm)form;
+ copyAuthoringFormValuesIntoFormBean(request, nbForm);
+
+ INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext());
+ String idAsString = nbForm.getToolContentID();
+ if (idAsString == null)
+ {
+ String error = "Unable to continue. Tool content id missing";
+ logger.error(error);
+ throw new NbApplicationException(error);
+ }
+ Long content_id = NbWebUtil.convertToLong(nbForm.getToolContentID());
+
+ //throws exception if the content id does not exist
+ checkContentId(content_id);
+
+ NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id);
+ nbForm.copyValuesIntoNbContent(nbContent);
+ /* Author has finished editing the content and mark the defineLater flag to false */
+ nbContent.setDefineLater(false);
+ nbService.updateNoticeboard(nbContent);
+
+ return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
+ }
+
+ /**
+ * This method will either upload an online instructions file or an offline instructions file.
+ * It will upload an online file if the bean property onlineFile is not null and similarly,
+ * will upload an offline file if the bean property offlineFile is not null.
+ * By using the term "upload", we are saving the file information on the local database (?)
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws NbApplicationException
+ */
+ public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws InvalidParameterException, FileNotFoundException, RepositoryCheckedException, IOException, NbApplicationException {
+
+
+ //set up the values in the map
+ //call the uploadFile method from toolContentHandler
+ NbAuthoringForm nbForm = (NbAuthoringForm)form;
+ copyAuthoringFormValuesIntoFormBean(request, nbForm);
+ FormFile theFile;
+ INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext());
+
+ Long content_id = NbWebUtil.convertToLong(nbForm.getToolContentID());
+ //throws exception if the content id does not exist
+ checkContentId(content_id);
+ NoticeboardContent nbContent = nbService.retrieveNoticeboard(content_id);
+
+ //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
+
+ if ((nbForm.getOnlineFile() != null && (nbForm.getOnlineFile().getFileName().trim().length() != 0)) ||
+ (nbForm.getOfflineFile() != null && (nbForm.getOfflineFile().getFileName().trim().length() != 0)))
+ {
+ boolean isOnlineFile = ((nbForm.getOnlineFile() != null && (nbForm.getOnlineFile().getFileName().trim().length() != 0)) ? true: false );
+ theFile = (isOnlineFile ? nbForm.getOnlineFile() : nbForm.getOfflineFile());
+ String fileType = isOnlineFile ? NoticeboardAttachment.TYPE_ONLINE : NoticeboardAttachment.TYPE_OFFLINE;
+
+ //check to see if FileExists
+ NoticeboardAttachment file = nbService.retrieveAttachmentByFilename(theFile.getFileName());
+
+
+ try
+ {
+
+ if (fileExists(content_id, file, isOnlineFile))
+ {
+ /**
+ * The same file belonging to the same toolcontent id already exists.
+ * The old version of this file is deleted from the content repository
+ * and the new one is saved in the content repository.
+ *
+ * The entry in the database is then updated with the new uuid and version
+ */
+ getToolContentHandler().deleteFile(file.getUuid());
+
+ nbService.removeAttachment(file);
+
+ /* NodeKey node = getToolContentHandler().uploadFile(theFile.getInputStream(), theFile.getFileName(),
+ theFile.getContentType(), fileType);
+
+ file.setUuid(node.getUuid()); //only need to update the uuid, the rest of the info is the same
+ file.setVersionId(node.getVersion());
+ nbService.saveAttachment(file); */
+
+ }
+ /**
+ * This is a new file and so is saved to the content repository.
+ *
+ * A new entry is added to the database.
+ */
+ NodeKey node = getToolContentHandler().uploadFile(theFile.getInputStream(), theFile.getFileName(),
+ theFile.getContentType(), fileType);
+ file = new NoticeboardAttachment();
+ file.setFilename(theFile.getFileName());
+ file.setOnlineFile(isOnlineFile);
+ file.setNbContent(nbContent);
+ file.setUuid(node.getUuid());
+ file.setVersionId(node.getVersion());
+ nbService.saveAttachment(file);
+
+
+ String keyName = file.returnKeyName();
+
+ //add the files to the map
+ Map attachmentMap = nbForm.getAttachments();
+ if (!attachmentMap.containsKey(keyName))
+ {
+ attachmentMap.put(keyName, file);
+ }
+
+ NbWebUtil.addUploadsToSession(request, attachmentMap);
+ //reset the fields so that more files can be uploaded
+ nbForm.setOfflineFile(null);
+ nbForm.setOnlineFile(null);
+ }
+ catch (FileNotFoundException e) {
+ logger.error("Unable to uploadfile",e);
+ throw new NbApplicationException("Unable to upload file, exception was "+e.getMessage());
+ } catch (IOException e) {
+ logger.error("Unable to uploadfile",e);
+ throw new NbApplicationException("Unable to upload file, exception was "+e.getMessage());
+ } catch (RepositoryCheckedException e) {
+ logger.error("Unable to uploadfile",e);
+ throw new NbApplicationException("Unable to upload file, exception was "+e.getMessage());
+ }
+ }
+
+ nbForm.setMethod(NoticeboardConstants.INSTRUCTIONS);
+
+ return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
+ }
+
+
+ public ActionForward deleteAttachment(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ throws InvalidParameterException, RepositoryCheckedException, NbApplicationException {
+
+ Long uuid = NbWebUtil.convertToLong(request.getParameter(NoticeboardConstants.UUID));
+
+ NbAuthoringForm nbForm = (NbAuthoringForm)form;
+ // copyAuthoringFormValuesIntoFormBean(request, nbForm);
+
+ INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext());
+
+ if (uuid == null)
+ {
+ String error = "Unable to continue. The file uuid is missing.";
+ logger.error(error);
+ throw new NbApplicationException(error);
+ }
+ NoticeboardAttachment attachment = nbService.retrieveAttachmentByUuid(uuid);
+ if (attachment == null)
+ {
+ String error = "Unable to continue. The file does not exist";
+ logger.error(error);
+ throw new NbApplicationException(error);
+
+ }
+ String keyName = attachment.returnKeyName();
+
+ //remove entry from map
+ Map attachmentMap = nbForm.getAttachments();
+ attachmentMap.remove(keyName);
+ NbWebUtil.addUploadsToSession(request, attachmentMap);
+
+ //remove entry from content repository
+ try
+ {
+ getToolContentHandler().deleteFile(uuid);
+ }
+ catch (RepositoryCheckedException e) {
+ logger.error("Unable to delete file",e);
+ throw new NbApplicationException("Unable to delete file, exception was "+e.getMessage());
+ }
+
+ //remove entry from db
+ nbService.removeAttachment(attachment);
+
+ nbForm.setMethod(NoticeboardConstants.INSTRUCTIONS);
+
+ return mapping.findForward(NoticeboardConstants.AUTHOR_PAGE);
+ }
+
+
+
+ /**
+ * It is assumed that the contentId is passed as a http parameter
+ * if the contentId is null, an exception is thrown, otherwise proceed as normal
+ *
+ * @param contentId the toolContentId to check
+ */
+ private void checkContentId(Long contentId)
+ {
+ if (contentId == null)
+ {
+ String error = "Unable to continue. Tool content id missing.";
+
+ throw new NbApplicationException(error);
+ }
+ }
+
+ /**
+ * This method copies the values of the request parameters richTextOnlineInstructions
+ * richTextOfflineInstructionsrichTextContent into the form properties
+ * onlineInstructions, offlineInstructions and content respectively.
+ *
+ * @param request HttpServlet request
+ * @param form The ActionForm class containing data submitted by the forms.
+ */
+ private void copyAuthoringFormValuesIntoFormBean(HttpServletRequest request, NbAuthoringForm form)
+ {
+ String onlineInstruction = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_ONLINE_INSTRN, true);
+ String offlineInstruction = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_OFFLINE_INSTRN, true);
+ String content = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_CONTENT, true);
+ String title = WebUtil.readStrParam(request, NoticeboardConstants.RICH_TEXT_TITLE, true);
- if(title != null)
- form.setTitle(title);
- if(content != null)
- form.setContent(content);
- if(onlineInstruction != null)
- form.setOnlineInstructions(onlineInstruction);
- if(offlineInstruction != null)
- form.setOfflineInstructions(offlineInstruction);
-
- }
- /**
- * This method checks whether a file
- * already exists in the database. If this file already exists, then the
- * type of file is checked, along with the associated toolContentId.
- * If both files are also of the same type, ie.
- * both are offline files or both are online files and the tool content Id matches
- * toolContentId, 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)
- {
- /**
- * TODO: check whether they refer to the same contentIdk
- */
- 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;
- }
- }
+
+ form.setTitle(title);
+
+ form.setContent(content);
+
+ form.setOnlineInstructions(onlineInstruction);
+
+ form.setOfflineInstructions(offlineInstruction);
+
+ }
+
+ /* private void copyFormValuesIntoNbContent(HttpServletRequest request, NoticeboardContent nbContent)
+ {
+ nbContent.setTitle((String)request.getParameter(NoticeboardConstants.RICH_TEXT_TITLE));
+ nbContent.setContent((String)request.getParameter(NoticeboardConstants.RICH_TEXT_CONTENT));
+ nbContent.setOnlineInstructions((String)request.getParameter(NoticeboardConstants.RICH_TEXT_ONLINE_INSTRN));
+ nbContent.setOfflineInstructions((String)request.getParameter(NoticeboardConstants.RICH_TEXT_OFFLINE_INSTRN));
+
+ } */
+
+
+
+
+
+ /**
+ * This method checks whether a file
+ * already exists in the database. If this file already exists, then the
+ * type of file is checked, along with the associated toolContentId.
+ * If both files are also of the same type, ie.
+ * both are offline files or both are online files and the tool content Id matches
+ * toolContentId, 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;
+ }
+ }
+
+
+}
-
-
-
-
-
-
-
-
-
-}
\ No newline at end of file
Fisheye: Tag 1.5 refers to a dead (removed) revision in file `lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringV2Action.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.4 refers to a dead (removed) revision in file `lams_tool_nb/web/a_Advanced.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.5 refers to a dead (removed) revision in file `lams_tool_nb/web/a_Basic.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.10 refers to a dead (removed) revision in file `lams_tool_nb/web/a_Instructions.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 1.3 refers to a dead (removed) revision in file `lams_tool_nb/web/authorContent.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_nb/web/author_page.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_nb/web/Attic/author_page.jsp,v
diff -u -r1.4 -r1.5
--- lams_tool_nb/web/author_page.jsp 13 Sep 2005 04:14:06 -0000 1.4
+++ lams_tool_nb/web/author_page.jsp 9 Nov 2005 22:03:49 -0000 1.5
@@ -1,33 +1,26 @@
-<%@ taglib uri="/WEB-INF/struts/struts-html-el.tld" prefix="html" %>
-<%@ taglib uri="/WEB-INF/jstl/fmt.tld" prefix="fmt" %>
-<%@ taglib uri="/WEB-INF/jstl/c.tld" prefix="c" %>
-<%@ taglib uri="/WEB-INF/struts/struts-bean.tld" prefix="bean" %>
-<%@ taglib uri="/WEB-INF/struts/struts-logic.tld" prefix="logic" %>
-<%@ taglib uri="fck-editor" prefix="FCK" %>
+<%@ taglib uri="tags-html-el" prefix="html" %>
+<%@ taglib uri="tags-fmt" prefix="fmt" %>
+<%@ taglib uri="tags-core" prefix="c" %>
+<%@ taglib uri="tags-bean" prefix="bean" %>
+<%@ taglib uri="tags-logic" prefix="logic" %>
+<%@ taglib uri="tags-fck-editor" prefix="FCK" %>
+<%@ taglib uri="tags-lams" prefix="lams" %>
-<%
-String protocol = request.getProtocol();
-if(protocol.startsWith("HTTPS")){
- protocol = "https://";
-}else{
- protocol = "http://";
-}
-String root = protocol+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
-String pathToLams = protocol+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/../..";
+
+
-%>
-
-
+
+
Noticeboard tool
-
-
+includes/javascript/tabcontroller.js">
+includes/javascript/common.js">
-
+css/tool_custom.css" rel="stylesheet" type="text/css">
-
+
-
+