Index: lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/servlets/ExportServlet.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/servlets/ExportServlet.java,v diff -u -r1.2 -r1.3 --- lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/servlets/ExportServlet.java 12 May 2009 01:39:00 -0000 1.2 +++ lams_tool_mindmap/src/java/org/lamsfoundation/lams/tool/mindmap/web/servlets/ExportServlet.java 13 May 2009 08:35:43 -0000 1.3 @@ -28,7 +28,9 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.util.Iterator; import java.util.List; +import java.util.Set; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; @@ -61,34 +63,86 @@ private static final long serialVersionUID = -2829707715037631881L; private static Logger logger = Logger.getLogger(ExportServlet.class); + private final String ERROR = "error.html"; private final String FILENAME = "mindmap_main.html"; private IMindmapService mindmapService; protected String doExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) { + String basePath = + request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath(); if (mindmapService == null) { mindmapService = MindmapServiceProxy.getMindmapService(getServletContext()); } try { + // exporting Flash and JavaScript files + writeResponseToFile(basePath + "/images/mindmap_locked.swf", directoryName, "mindmap.swf", cookies); + writeResponseToFile(basePath + "/includes/javascript/swfobject.js", directoryName, "swfobject.js", cookies); + writeResponseToFile(basePath + "/includes/javascript/mindmap.resize.js", directoryName, "resize.js", cookies); + writeResponseToFile(Configuration.get(ConfigurationKeys.SERVER_URL) + + "includes/javascript/jquery-latest.pack.js", directoryName, "jquery.js", cookies); + + try { + File localeFile = new File(directoryName + "/locale.xml"); + FileOutputStream fop = new FileOutputStream(localeFile); + fop.write(mindmapService.getLanguageXML().getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + if (StringUtils.equals(mode, ToolAccessMode.LEARNER.toString())) { request.getSession().setAttribute(AttributeNames.ATTR_MODE, ToolAccessMode.LEARNER); doLearnerExport(request, response, directoryName, cookies); - } else if (StringUtils.equals(mode, ToolAccessMode.TEACHER.toString())) { + writeResponseToFile(basePath + "/pages/export/exportPortfolio.jsp", directoryName, FILENAME, cookies); + + return FILENAME; + } + else if (StringUtils.equals(mode, ToolAccessMode.TEACHER.toString())) { request.getSession().setAttribute(AttributeNames.ATTR_MODE, ToolAccessMode.TEACHER); - doTeacherExport(request, response, directoryName, cookies); + + Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); + + if (mindmap.isMultiUserMode()) { + doTeacherMultiModeExport(request, response, directoryName, cookies); + writeResponseToFile(basePath + "/pages/export/exportPortfolioMultimode.jsp", directoryName, FILENAME, cookies); + + return FILENAME; + } + else { + MindmapDTO mindmapDTO = new MindmapDTO(mindmap); + mindmapDTO.setTitle(mindmap.getTitle()); + mindmapDTO.setInstructions(mindmap.getInstructions()); + + Set sessionDTOs = mindmapDTO.getSessionDTOs(); + for (Iterator iterator = sessionDTOs.iterator(); iterator.hasNext();) { + MindmapSessionDTO mindmapSessionDTO = (MindmapSessionDTO) iterator.next(); + + Set userDTOs = mindmapSessionDTO.getUserDTOs(); + for (Iterator userIterator = userDTOs.iterator(); userIterator.hasNext();) { + MindmapUserDTO mindmapUserDTO = (MindmapUserDTO) userIterator.next(); + MindmapUser mindmapUser = mindmapService.getUserByUID(mindmapUserDTO.getUid()); + String filename = mindmapUser.getFirstName() + "_" + mindmapUser.getLastName() + + "_" + mindmapUser.getUid() + ".html"; + + doTeacherSingleModeExport(request, response, directoryName, cookies, mindmap, mindmapUser); + writeResponseToFile(basePath + "/pages/export/exportPortfolioMultimode.jsp", directoryName, filename, cookies); + } + } + + request.getSession().setAttribute("mindmapDTO", mindmapDTO); + + writeResponseToFile(basePath + "/pages/export/exportPortfolioMultimodeLinks.jsp", directoryName, FILENAME, cookies); + + return FILENAME; + } } } catch (MindmapException e) { logger.error("Cannot perform export for Mindmap tool!"); } - - String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() - + request.getContextPath(); - - writeResponseToFile(basePath + "/pages/export/exportPortfolio.jsp", directoryName, FILENAME, cookies); - - return FILENAME; + + return ERROR; } protected String doOfflineExport(HttpServletRequest request, HttpServletResponse response, String directoryName, @@ -114,7 +168,39 @@ } return super.doOfflineExport(request, response, directoryName, cookies); } + + private void exportMindmapNodes(List mindmapNodeList, Mindmap mindmap, MindmapUser mindmapUser, String path) + { + if (mindmapNodeList != null && mindmapNodeList.size() > 0) { + MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); + String mindmapUserName = null; + if (rootMindmapNode.getUser() == null) + mindmapUserName = mindmapService.getMindmapMessageService().getMessage("node.instructor.label"); + else + mindmapUserName = rootMindmapNode.getUser().getFirstName() + " " + rootMindmapNode.getUser().getLastName(); + + NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), + rootMindmapNode.getText(), rootMindmapNode.getColor(), mindmapUserName)); + + NodeModel currentNodeModel = mindmapService.getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), + mindmap.getUid(), rootNodeModel, mindmapUser); + + XStream xstream = new XStream(); + xstream.alias("branch", NodeModel.class); + String mindmapContent = xstream.toXML(currentNodeModel); + + try { + File mindmapFile = new File(path); + FileOutputStream fop = new FileOutputStream(mindmapFile); + fop.write(mindmapContent.getBytes()); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + private void doLearnerExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) throws MindmapException { @@ -148,162 +234,74 @@ // adding Mindmap files to archive request.getSession().setAttribute("mindmapContentPath", "mindmap.xml"); - + request.getSession().setAttribute("localizationPath", "locale.xml"); + String currentMindmapUser = mindmapUser.getFirstName() + " " + mindmapUser.getLastName(); request.getSession().setAttribute("currentMindmapUser", currentMindmapUser); - - request.getSession().setAttribute("localizationPath", "locale.xml"); - String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() - + request.getContextPath(); - writeResponseToFile(basePath + "/images/mindmap_locked.swf", directoryName, "mindmap.swf", cookies); - writeResponseToFile(basePath + "/includes/javascript/swfobject.js", directoryName, "swfobject.js", cookies); - writeResponseToFile(basePath + "/includes/javascript/mindmap.resize.js", directoryName, "resize.js", cookies); - writeResponseToFile(Configuration.get(ConfigurationKeys.SERVER_URL) - + "includes/javascript/jquery-latest.pack.js", directoryName, "jquery.js", cookies); - List mindmapNodeList = null; if (mindmap.isMultiUserMode()) // is multi-user mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapSession(mindmap.getUid(), toolSessionID); else mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); - if (mindmapNodeList != null && mindmapNodeList.size() > 0) { - MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); + exportMindmapNodes(mindmapNodeList, mindmap, mindmapUser, directoryName + "/mindmap.xml"); - String mindmapUserName = null; - if (rootMindmapNode.getUser() == null) - mindmapUserName = mindmapService.getMindmapMessageService().getMessage("node.instructor.label"); - else - mindmapUserName = rootMindmapNode.getUser().getFirstName() + " " - + rootMindmapNode.getUser().getLastName(); - - NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode - .getText(), rootMindmapNode.getColor(), mindmapUserName)); - - NodeModel currentNodeModel = mindmapService.getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), - mindmap.getUid(), rootNodeModel, mindmapUser); - - XStream xstream = new XStream(); - xstream.alias("branch", NodeModel.class); - String mindmapContent = xstream.toXML(currentNodeModel); - - try { - File mindmapFile = new File(directoryName + "/mindmap.xml"); - FileOutputStream fop = new FileOutputStream(mindmapFile); - fop.write(mindmapContent.getBytes()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - try { - File localeFile = new File(directoryName + "/locale.xml"); - FileOutputStream fop = new FileOutputStream(localeFile); - fop.write(mindmapService.getLanguageXML().getBytes()); - } catch (IOException e) { - e.printStackTrace(); - } - request.getSession().setAttribute("mindmapDTO", mindmapDTO); } - private void doTeacherExport(HttpServletRequest request, HttpServletResponse response, String directoryName, + private void doTeacherSingleModeExport(HttpServletRequest request, HttpServletResponse response, String directoryName, + Cookie[] cookies, Mindmap mindmap, MindmapUser mindmapUser) throws MindmapException { + + logger.debug("doTeacherSingleModeExport: toolContentID: " + toolContentID); + + String filename = mindmapUser.getFirstName() + "_" + mindmapUser.getLastName() + + "_" + mindmapUser.getUid(); + + request.getSession().setAttribute("mindmapContentPath", filename + ".xml"); + request.getSession().setAttribute("localizationPath", "locale.xml"); + + String currentMindmapUser = mindmapUser.getFirstName() + " " + mindmapUser.getLastName(); + request.getSession().setAttribute("currentMindmapUser", currentMindmapUser); + + List mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); + + exportMindmapNodes(mindmapNodeList, mindmap, mindmapUser, directoryName + "/" + filename + ".xml"); + } + + private void doTeacherMultiModeExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) throws MindmapException { - logger.debug("doExportTeacher: toolContentID:" + toolContentID); + logger.debug("doExportTeacher: toolContentID: " + toolContentID); // check if toolContentID available if (toolContentID == null) { String error = "Tool Content ID is missing. Unable to continue"; logger.error(error); throw new MindmapException(error); } - - //Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); - //MindmapDTO mindmapDTO = new MindmapDTO(mindmap); - - - MindmapSession mindmapSession = mindmapService.getSessionBySessionId(toolSessionID); - //Mindmap mindmap = mindmapSession.getMindmap(); Mindmap mindmap = mindmapService.getMindmapByContentId(toolContentID); - //Long userID = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID); - MindmapUser mindmapUser = null; //mindmapService.getUserByUserIdAndSessionId(userID, toolSessionID); - - // construct dto's MindmapDTO mindmapDTO = new MindmapDTO(mindmap); mindmapDTO.setTitle(mindmap.getTitle()); mindmapDTO.setInstructions(mindmap.getInstructions()); - - //MindmapSessionDTO sessionDTO = new MindmapSessionDTO(); - //sessionDTO.setSessionName(mindmapSession.getSessionName()); - //sessionDTO.setSessionID(mindmapSession.getSessionId()); - - //MindmapUserDTO userDTO = new MindmapUserDTO(mindmapUser); - - //sessionDTO.getUserDTOs().add(userDTO); - //mindmapDTO.getSessionDTOs().add(sessionDTO); - - // adding Mindmap files to archive - request.getSession().setAttribute("mindmapContentPath", "mindmap.xml"); - - //String currentMindmapUser = mindmapUser.getFirstName() + " " + mindmapUser.getLastName(); - //request.getSession().setAttribute("currentMindmapUser", currentMindmapUser); request.getSession().setAttribute("localizationPath", "locale.xml"); - - String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() - + request.getContextPath(); - writeResponseToFile(basePath + "/images/mindmap_locked.swf", directoryName, "mindmap.swf", cookies); - writeResponseToFile(basePath + "/includes/javascript/swfobject.js", directoryName, "swfobject.js", cookies); - writeResponseToFile(basePath + "/includes/javascript/mindmap.resize.js", directoryName, "resize.js", cookies); - writeResponseToFile(Configuration.get(ConfigurationKeys.SERVER_URL) - + "includes/javascript/jquery-latest.pack.js", directoryName, "jquery.js", cookies); - List mindmapNodeList = null; - if (mindmap.isMultiUserMode()) // is multi-user - mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapSession(mindmap.getUid(), toolSessionID); - else - mindmapNodeList = mindmapService.getRootNodeByMindmapIdAndUserId(mindmap.getUid(), mindmapUser.getUid()); - - if (mindmapNodeList != null && mindmapNodeList.size() > 0) { - MindmapNode rootMindmapNode = (MindmapNode) mindmapNodeList.get(0); - - String mindmapUserName = null; - if (rootMindmapNode.getUser() == null) - mindmapUserName = mindmapService.getMindmapMessageService().getMessage("node.instructor.label"); - else - mindmapUserName = rootMindmapNode.getUser().getFirstName() + " " - + rootMindmapNode.getUser().getLastName(); - - NodeModel rootNodeModel = new NodeModel(new NodeConceptModel(rootMindmapNode.getUniqueId(), rootMindmapNode - .getText(), rootMindmapNode.getColor(), mindmapUserName)); - - NodeModel currentNodeModel = mindmapService.getMindmapXMLFromDatabase(rootMindmapNode.getNodeId(), - mindmap.getUid(), rootNodeModel, mindmapUser); - - XStream xstream = new XStream(); - xstream.alias("branch", NodeModel.class); - String mindmapContent = xstream.toXML(currentNodeModel); - - try { - File mindmapFile = new File(directoryName + "/mindmap.xml"); - FileOutputStream fop = new FileOutputStream(mindmapFile); - fop.write(mindmapContent.getBytes()); - } catch (IOException e) { - e.printStackTrace(); + // if Mindmap is in Multi-mode + if (mindmap.isMultiUserMode()) + { + Set sessionDTOs = mindmapDTO.getSessionDTOs(); + for (Iterator iterator = sessionDTOs.iterator(); iterator.hasNext();) { + MindmapSessionDTO mindmapSessionDTO = (MindmapSessionDTO) iterator.next(); + + List mindmapNodeList = mindmapService.getAuthorRootNodeByMindmapSession(mindmap.getUid(), mindmapSessionDTO.getSessionID()); + + exportMindmapNodes(mindmapNodeList, mindmap, null, directoryName + "/mindmap.xml"); } } - - try { - File localeFile = new File(directoryName + "/locale.xml"); - FileOutputStream fop = new FileOutputStream(localeFile); - fop.write(mindmapService.getLanguageXML().getBytes()); - } catch (IOException e) { - e.printStackTrace(); - } - + request.getSession().setAttribute("mindmapDTO", mindmapDTO); } + } Index: lams_tool_mindmap/web/pages/export/exportPortfolio.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/web/pages/export/Attic/exportPortfolio.jsp,v diff -u -r1.2 -r1.3 --- lams_tool_mindmap/web/pages/export/exportPortfolio.jsp 12 May 2009 01:38:45 -0000 1.2 +++ lams_tool_mindmap/web/pages/export/exportPortfolio.jsp 13 May 2009 08:35:26 -0000 1.3 @@ -1,5 +1,4 @@ - + <%@ include file="/common/taglibs.jsp"%> @@ -65,7 +64,7 @@ @@ -86,6 +85,7 @@ + @@ -95,4 +95,3 @@ - Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_mindmap/web/pages/export/exportPortfolioMultimode.jsp'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1 refers to a dead (removed) revision in file `lams_tool_mindmap/web/pages/export/exportPortfolioMultimodeLinks.jsp'. Fisheye: No comparison available. Pass `N' to diff?
- ${user.firstName} ${user.lastName } + ${user.firstName} ${user.lastName}