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 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/util/NbWebUtil.java 20 Jul 2005 05:26:55 -0000 1.1 @@ -0,0 +1,115 @@ +/* + *Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * + *This program is free software; you can redistribute it and/or modify + *it under the terms of the GNU General Public License as published by + *the Free Software Foundation; either version 2 of the License, or + *(at your option) any later version. + * + *This program is distributed in the hope that it will be useful, + *but WITHOUT ANY WARRANTY; without even the implied warranty of + *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + *GNU General Public License for more details. + * + *You should have received a copy of the GNU General Public License + *along with this program; if not, write to the Free Software + *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + *USA + * + *http://www.gnu.org/licenses/gpl.txt + */ + + +/* + * Created on Jul 20, 2005 + * + * TODO To change the template for this generated file go to + * Window - Preferences - Java - Code Style - Code Templates + */ +package org.lamsfoundation.lams.tool.noticeboard.util; + + +import javax.servlet.http.HttpServletRequest; + +import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; +import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; + +/** + * @author mtruong + * + * TODO To change the template for this generated type comment go to + * Window - Preferences - Java - Code Style - Code Templates + */ +public class NbWebUtil { + + private NbWebUtil() {} + + /** + * Converts the request parameter toolContentId, from a string to a Long + * @author mtruong + */ + + public static Long convertToLong(String toolContentId) + { + Long contentId = new Long(Long.parseLong(toolContentId)); + return contentId; + } + + public static void cleanAuthoringSession(HttpServletRequest request) + { + request.getSession().removeAttribute(NoticeboardConstants.TOOL_CONTENT_ID); + } + + public static void cleanLearnerSession(HttpServletRequest request) + { + request.getSession().removeAttribute(NoticeboardConstants.READ_ONLY_MODE); + // request.getSession().removeAttribute(NoticeboardConstants.IS_TOOL_COMPLETED); + } + + public static void cleanMonitoringSession(HttpServletRequest request) + { + request.getSession().removeAttribute(NoticeboardConstants.TOOL_CONTENT_ID_INMONITORMODE); + request.getSession().removeAttribute(NoticeboardConstants.TITLE); + request.getSession().removeAttribute(NoticeboardConstants.CONTENT); + request.getSession().removeAttribute(NoticeboardConstants.OFFLINE_INSTRUCTIONS); + request.getSession().removeAttribute(NoticeboardConstants.ONLINE_INSTRUCTIONS); + + } + + /** + *

This method checks the two tool content flags, defineLater and contentInUse + * to determine whether the tool content is modifiable or not. Returns true is content is + * modifiable and false otherwise + *
Tool content is modifiable if: + *

  • defineLater is set to true
  • + *
  • defineLater is set to false and contentInUse is set to false
  • + *
    Tool content is not modifiable if: + *
  • contentInUse is set to true
  • + * @param content The instance of NoticeboardContent to check + * @return true if content is modifiable and false otherwise + * @throws NbApplicationException + */ + public static boolean isContentEditable(NoticeboardContent content) throws NbApplicationException + { + if ( (content.isDefineLater() == true) && (content.isContentInUse()==true) ) + { + throw new NbApplicationException("An exception has occurred: There is a bug in this tool, conflicting flags are set"); + //return false; + } + else if ( (content.isDefineLater() == true) && (content.isContentInUse() == false)) + return true; + else if ( (content.isDefineLater() == false) && (content.isContentInUse() == false)) + return true; + else // (content.isContentInUse()==true && content.isDefineLater() == false) + return false; + } + + public static void copyValuesIntoSession(HttpServletRequest request, NoticeboardContent content) + { + request.getSession().setAttribute(NoticeboardConstants.TITLE, content.getTitle()); + request.getSession().setAttribute(NoticeboardConstants.CONTENT, content.getContent()); + request.getSession().setAttribute(NoticeboardConstants.ONLINE_INSTRUCTIONS, content.getOnlineInstructions()); + request.getSession().setAttribute(NoticeboardConstants.OFFLINE_INSTRUCTIONS, content.getOfflineInstructions()); + } +} 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.5 -r1.6 --- lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 20 Jul 2005 04:13:18 -0000 1.5 +++ lams_tool_nb/src/java/org/lamsfoundation/lams/tool/noticeboard/web/NbAuthoringAction.java 20 Jul 2005 05:27:45 -0000 1.6 @@ -35,14 +35,12 @@ import org.lamsfoundation.lams.tool.noticeboard.NoticeboardConstants; import org.lamsfoundation.lams.tool.noticeboard.NoticeboardContent; import org.lamsfoundation.lams.tool.noticeboard.NbApplicationException; - +import org.lamsfoundation.lams.tool.noticeboard.util.NbWebUtil; import org.lamsfoundation.lams.tool.noticeboard.service.INoticeboardService; import org.lamsfoundation.lams.tool.noticeboard.service.NoticeboardServiceProxy; -import org.lamsfoundation.lams.tool.noticeboard.util.NbAuthoringUtil; import org.lamsfoundation.lams.util.WebUtil; - /** * Creation Date: 20-05-05 * Modified Date: 03-06-05 @@ -129,7 +127,7 @@ copyInstructionFormProperty(request, nbForm); INoticeboardService nbService = NoticeboardServiceProxy.getNbService(getServlet().getServletContext()); - Long content_id = NbAuthoringUtil.convertToLong(nbForm.getToolContentId()); + Long content_id = NbWebUtil.convertToLong(nbForm.getToolContentId()); //throws exception if the content id does not exist checkContentId(content_id); @@ -139,14 +137,7 @@ /* Author has finished editing the content and mark the defineLater flag to false */ nbContent.setDefineLater(false); nbService.updateNoticeboard(nbContent); - - if(request.getSession().getAttribute(NoticeboardConstants.DEFINE_LATER) != null) - { - //if defineLater session variable is set (set in monitoring by edit activity action , reset/remove this attribute. */ - request.getSession().setAttribute(NoticeboardConstants.DEFINE_LATER, "false"); - } - - + return mapping.findForward(NoticeboardConstants.BASIC_PAGE); /** TODO: once the content is saved, should close the window */ }