Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -ra2bfe0110d8572642cf5f19fc3e2882252fdd43b -r078ffcc5cce6214e179857ace04486fa04a7e3a2 Binary files differ Index: lams_central/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r07865c855b32c77613ed72dd81cd499033dca4dd -r078ffcc5cce6214e179857ace04486fa04a7e3a2 --- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 07865c855b32c77613ed72dd81cd499033dca4dd) +++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) @@ -164,7 +164,6 @@ title.export.choose.format =Choose export content format msg.export.choose.format.instruction =Please choose format which you want to export msg.export.choose.format.lams =LAMS Format -msg.export.choose.format.ims =IMS Learning Design Level A Format (This format cannot be reimported back into LAMS. Export only!) button.export =Export label.open.lesson =Open Lesson label.msg.status =Status: {0} @@ -185,7 +184,6 @@ label.return.to.myprofile =Return to My Profile label.help =Help? label.completed =Completed! -msg.import.file.format =The import file must be a .zip file exported from LAMS 2 or above, or a .las file exported from LAMS 1.0.2. label.enable.lesson.sorting =Enable lesson sorting label.lesson.sorting.enabled =lesson sorting enabled label.show.groups =Show Groups @@ -565,9 +563,6 @@ authoring.fla.page.menu.saveas =Save as authoring.fla.page.menu.export =Export authoring.fla.page.menu.export.lams =Sequence LAMS -authoring.fla.page.menu.export.ims.tooltip =IMS Learning Design Level A Format \ - (This format cannot be reimported back into LAMS. Export only!) -authoring.fla.page.menu.export.ims =Sequence IMS authoring.fla.page.menu.export.png =Image PNG authoring.fla.page.menu.export.svg =Image SVG authoring.fla.page.menu.copy =Copy Index: lams_central/src/java/org/lamsfoundation/lams/authoring/web/ExportToolContentAction.java =================================================================== diff -u -r56c565f6b6e596ec0de434127769de8986a090be -r078ffcc5cce6214e179857ace04486fa04a7e3a2 --- lams_central/src/java/org/lamsfoundation/lams/authoring/web/ExportToolContentAction.java (.../ExportToolContentAction.java) (revision 56c565f6b6e596ec0de434127769de8986a090be) +++ lams_central/src/java/org/lamsfoundation/lams/authoring/web/ExportToolContentAction.java (.../ExportToolContentAction.java) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) @@ -25,14 +25,10 @@ package org.lamsfoundation.lams.authoring.web; import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import java.io.InputStreamReader; import java.io.OutputStream; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -49,7 +45,6 @@ import org.lamsfoundation.lams.util.FileUtil; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsAction; -import org.lamsfoundation.lams.web.lamscommunity.LamsCommunityUtil; import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; @@ -60,19 +55,15 @@ * @struts.action-forward name = "loading" path = "/toolcontent/exportloading.jsp" * @struts.action-forward name = "result" path = "/toolcontent/exportresult.jsp" * - * Export tool content action. It needs learingDesignID as input parameter. + * Export tool content action. It needs learingDesignID as input parameter. * @author Steve.Ni * @version $Revision$ */ public class ExportToolContentAction extends LamsAction { - private static final long serialVersionUID = 1L; public static final String PARAM_LEARING_DESIGN_ID = "learningDesignID"; public static final String ATTR_TOOLS_ERROR_MESSAGE = "toolsErrorMessages"; public static final String ATTR_LD_ERROR_MESSAGE = "ldErrorMessages"; - private static final String PARAM_EXPORT_FORMAT = "format"; - private static final String IMS_XSLT_NAME = "learning-design-ims.xslt"; - private static final String IMS_XSLT_PATH = "/toolcontent"; private Logger log = Logger.getLogger(ExportToolContentAction.class); @@ -84,8 +75,6 @@ if (StringUtils.equals(param, "loading")) { Long learningDesignId = WebUtil.readLongParam(request, ExportToolContentAction.PARAM_LEARING_DESIGN_ID); request.setAttribute(ExportToolContentAction.PARAM_LEARING_DESIGN_ID, learningDesignId); - int format = WebUtil.readIntParam(request, ExportToolContentAction.PARAM_EXPORT_FORMAT); - request.setAttribute(ExportToolContentAction.PARAM_EXPORT_FORMAT, format); // display initial page for automatically loading download pgm return mapping.findForward("loading"); } else if (StringUtils.equals(param, "export")) { @@ -101,16 +90,12 @@ private ActionForward exportLD(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response) { Long learningDesignId = WebUtil.readLongParam(request, ExportToolContentAction.PARAM_LEARING_DESIGN_ID); - int format = WebUtil.readIntParam(request, ExportToolContentAction.PARAM_EXPORT_FORMAT); IExportToolContentService service = getExportService(); List ldErrorMsgs = new ArrayList(); List toolsErrorMsgs = new ArrayList(); try { - File xslt = new File(this.getServlet().getServletContext().getRealPath( - ExportToolContentAction.IMS_XSLT_PATH) - + File.separator + ExportToolContentAction.IMS_XSLT_NAME); - String zipFilename = service.exportLearningDesign(learningDesignId, toolsErrorMsgs, format, xslt); + String zipFilename = service.exportLearningDesign(learningDesignId, toolsErrorMsgs); // get only filename String zipfile = FileUtil.getFileName(zipFilename); @@ -170,70 +155,12 @@ return mapping.findForward("result"); } - /** - * Exports the learning design to lamscommunity - * - * @param mapping - * @param request - * @param response - * @return - */ - private ActionForward exportLDToLC(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response) { - Long learningDesignId = WebUtil.readLongParam(request, ExportToolContentAction.PARAM_LEARING_DESIGN_ID); - int format = WebUtil.readIntParam(request, ExportToolContentAction.PARAM_EXPORT_FORMAT); - IExportToolContentService service = getExportService(); - List ldErrorMsgs = new ArrayList(); - List toolsErrorMsgs = new ArrayList(); - - try { - File xslt = new File(this.getServlet().getServletContext().getRealPath( - ExportToolContentAction.IMS_XSLT_PATH) - + File.separator + ExportToolContentAction.IMS_XSLT_NAME); - String zipFilename = service.exportLearningDesign(learningDesignId, toolsErrorMsgs, format, xslt); - - // get only filename - String zipfile = FileUtil.getFileName(zipFilename); - - // replace spaces (" ") with underscores ("_") - - zipfile = zipfile.replaceAll(" ", "_"); - - File uploadFile = new File(zipfile); - if (uploadFile != null && uploadFile.exists()) { - HashMap authParams = LamsCommunityUtil.getAuthParams(); - InputStream is = WebUtil.performMultipartFilePost(uploadFile, - LamsCommunityUtil.LAMS_COMMUNITY_EXPORT_URL, zipFilename, authParams); - - BufferedReader isReader = new BufferedReader(new InputStreamReader(is)); - String responseStr = isReader.readLine(); - - if (responseStr != null && responseStr.trim().equals("success")) { - // successful export to lams community - // Get the ldID and forward user to the lamscommunity form - } else if (responseStr != null) { - // get the failure type and add it to the errors - } else { - // general failure - } - } - - return null; - } catch (Exception e1) { - log.error("Unable to export tool content: " + e1.toString()); - ldErrorMsgs.add(0, e1.getClass().getName()); - request.setAttribute(ExportToolContentAction.ATTR_LD_ERROR_MESSAGE, ldErrorMsgs); - request.setAttribute(ExportToolContentAction.ATTR_TOOLS_ERROR_MESSAGE, toolsErrorMsgs); - } - // display initial page for upload - return mapping.findForward("result"); - } - // *************************************************************************************** // Private method // *************************************************************************************** private IExportToolContentService getExportService() { - WebApplicationContext webContext = WebApplicationContextUtils.getRequiredWebApplicationContext(this - .getServlet().getServletContext()); + WebApplicationContext webContext = WebApplicationContextUtils + .getRequiredWebApplicationContext(this.getServlet().getServletContext()); return (IExportToolContentService) webContext.getBean(CentralConstants.EXPORT_TOOLCONTENT_SERVICE_BEAN_NAME); } } Index: lams_central/src/java/org/lamsfoundation/lams/web/planner/PedagogicalPlannerAction.java =================================================================== diff -u -re179b1c5a61d9aa11b2b3d9d741ad2674322aec4 -r078ffcc5cce6214e179857ace04486fa04a7e3a2 --- lams_central/src/java/org/lamsfoundation/lams/web/planner/PedagogicalPlannerAction.java (.../PedagogicalPlannerAction.java) (revision e179b1c5a61d9aa11b2b3d9d741ad2674322aec4) +++ lams_central/src/java/org/lamsfoundation/lams/web/planner/PedagogicalPlannerAction.java (.../PedagogicalPlannerAction.java) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) @@ -292,20 +292,21 @@ if (StringUtils.isBlank(copyMode) || PedagogicalPlannerAction.COPY_MODE_EDIT_CURRENT.equalsIgnoreCase(copyMode)) { // make sure user has priviledges - if (!isEditor - || ((node != null) && (node.getPermissions() != null) && ((node.getPermissions() & PedagogicalPlannerSequenceNode.PERMISSION_EDITOR_MODIFY) == 0))) { + if (!isEditor || ((node != null) && (node.getPermissions() != null) + && ((node.getPermissions() & PedagogicalPlannerSequenceNode.PERMISSION_EDITOR_MODIFY) == 0))) { PedagogicalPlannerAction.log.debug("Unauthorised attempt to openExistingTemplate (original)"); throw new UserAccessDeniedException(); } // modify the original design (a hard copy in user's folder) learningDesign = getAuthoringService().getLearningDesign(learningDesignId); copyMode = PedagogicalPlannerAction.COPY_MODE_EDIT_CURRENT; } else if (PedagogicalPlannerAction.COPY_MODE_MAKE_COPY.equalsIgnoreCase(copyMode)) { - if (isEditor ? (node != null) && (node.getPermissions() != null) - && ((node.getPermissions() & PedagogicalPlannerSequenceNode.PERMISSION_EDITOR_VIEW) == 0) - : (node != null) - && (node.getPermissions() != null) - && ((node.getPermissions() & PedagogicalPlannerSequenceNode.PERMISSION_TEACHER_COPY) == 0)) { + if (isEditor + ? (node != null) && (node.getPermissions() != null) + && ((node.getPermissions() + & PedagogicalPlannerSequenceNode.PERMISSION_EDITOR_VIEW) == 0) + : (node != null) && (node.getPermissions() != null) && ((node.getPermissions() + & PedagogicalPlannerSequenceNode.PERMISSION_TEACHER_COPY) == 0)) { PedagogicalPlannerAction.log.debug("Unauthorised attempt to openExistingTemplate (copy)"); throw new UserAccessDeniedException(); } @@ -316,8 +317,8 @@ request.setAttribute(CentralConstants.PARAM_COPY_MODE, copyMode); } if (learningDesign == null) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("no.such.learningdesign.exist", - new Object[] { learningDesignId })); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage("no.such.learningdesign.exist", new Object[] { learningDesignId })); } else { errors = openTemplate(request, learningDesign); } @@ -370,8 +371,8 @@ } } catch (ServletException e) { PedagogicalPlannerAction.log.error(e, e); - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); return errors; } @@ -437,8 +438,8 @@ originalDesign = getAuthoringService().getLearningDesign(originalDesignId); } if (originalDesign == null) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("no.such.learningdesign.exist", - new Object[] { originalDesignId })); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage("no.such.learningdesign.exist", new Object[] { originalDesignId })); return null; } User user = getUser(); @@ -448,8 +449,8 @@ String newDesignName = originalDesign.getTitle(); String customCSV = null; - return getAuthoringService().copyLearningDesign(originalDesign, copyType, user, targetFolder, - setOriginalDesign, newDesignName, customCSV); + return getAuthoringService().copyLearningDesign(originalDesign, copyType, user, targetFolder, setOriginalDesign, + newDesignName, customCSV); } /** @@ -531,9 +532,9 @@ } else if (activity.isGroupingActivity()) { // grouping is managed by this action class; GroupingActivity groupingActivity = (GroupingActivity) activity; - String pedagogicalPlannerUrl = WebUtil.appendParameterToURL(groupingActivity.getSystemTool() - .getPedagogicalPlannerUrl(), AttributeNames.PARAM_TOOL_CONTENT_ID, groupingActivity - .getCreateGrouping().getGroupingId().toString()); + String pedagogicalPlannerUrl = WebUtil.appendParameterToURL( + groupingActivity.getSystemTool().getPedagogicalPlannerUrl(), AttributeNames.PARAM_TOOL_CONTENT_ID, + groupingActivity.getCreateGrouping().getGroupingId().toString()); addedDTO = new PedagogicalPlannerActivityDTO(true, pedagogicalPlannerUrl); addedDTO.setTitle(activity.getTitle()); addedDTO.setToolIconUrl(PedagogicalPlannerAction.IMAGE_PATH_GROUPING); @@ -697,8 +698,9 @@ getMonitoringService().createPreviewClassForLesson(userDto.getUserID(), lesson.getLessonId()); getMonitoringService().startLesson(lesson.getLessonId(), userDto.getUserID()); - String newPath = WebUtil.appendParameterToURL(mapping.findForward(PedagogicalPlannerAction.FORWARD_PREVIEW) - .getPath(), AttributeNames.PARAM_LESSON_ID, lesson.getLessonId().toString()); + String newPath = WebUtil.appendParameterToURL( + mapping.findForward(PedagogicalPlannerAction.FORWARD_PREVIEW).getPath(), AttributeNames.PARAM_LESSON_ID, + lesson.getLessonId().toString()); newPath = WebUtil.appendParameterToURL(newPath, AttributeNames.PARAM_MODE, "preview"); return new ActionForward(newPath, true); } @@ -776,8 +778,8 @@ } catch (Exception e) { PedagogicalPlannerAction.log.error(e, e); ActionMessages errors = new ActionMessages(); - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_FILTER_PARSE)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_FILTER_PARSE)); saveErrors(request, errors); } } @@ -828,8 +830,9 @@ nodeForm.setPermissions(null); } else if (!importNode) { // We fill the form with necessary data - nodeForm.setNodeType(node.getLearningDesignId() == null ? PedagogicalPlannerSequenceNodeForm.NODE_TYPE_SUBNODES - : PedagogicalPlannerSequenceNodeForm.NODE_TYPE_TEMPLATE); + nodeForm.setNodeType( + node.getLearningDesignId() == null ? PedagogicalPlannerSequenceNodeForm.NODE_TYPE_SUBNODES + : PedagogicalPlannerSequenceNodeForm.NODE_TYPE_TEMPLATE); nodeForm.setRemoveTemplate(false); nodeForm.setTitle(dto.getTitle()); nodeForm.setBriefDescription(dto.getBriefDescription()); @@ -922,13 +925,13 @@ FileUtils.copyInputStreamToFile(inputStream, sourceFile); } catch (Exception e) { PedagogicalPlannerAction.log.error(e, e); - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_FILE_OPEN)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_FILE_OPEN)); } if (!sourceFile.exists() || sourceFile.isDirectory()) { PedagogicalPlannerAction.log.error(PedagogicalPlannerAction.ERROR_NOT_PROPER_FILE); - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_FILE_OPEN)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_FILE_OPEN)); } if (errors.isEmpty()) { LearningDesign learningDesign = importLearningDesign(sourceFile, errors); @@ -959,8 +962,8 @@ UserDTO u = (UserDTO) s.getAttribute(AttributeNames.USER); getPedagogicalPlannerDAO().saveNodeRole(u.getUserID(), nodeUid, Role.ROLE_SYSADMIN); } catch (Exception e) { - PedagogicalPlannerAction.log.error("Error saving role for newly created root node: " - + e.getMessage()); + PedagogicalPlannerAction.log + .error("Error saving role for newly created root node: " + e.getMessage()); e.printStackTrace(); } } @@ -999,12 +1002,13 @@ * @param form * @return */ - private ActionMessages validateNodeForm(PedagogicalPlannerSequenceNode node, PedagogicalPlannerSequenceNodeForm form) { + private ActionMessages validateNodeForm(PedagogicalPlannerSequenceNode node, + PedagogicalPlannerSequenceNodeForm form) { ActionMessages errors = new ActionMessages(); // Title must not be blank if (StringUtils.isEmpty(form.getTitle())) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_NODE_TITLE_BLANK)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_NODE_TITLE_BLANK)); } // Template must a proper file if (PedagogicalPlannerSequenceNodeForm.NODE_TYPE_TEMPLATE.equals(form.getNodeType()) @@ -1029,16 +1033,16 @@ boolean badExtension = false; if (fileName.length() >= 4) { String extension = fileName.substring(fileName.length() - 4); - if (!(extension.equalsIgnoreCase(PedagogicalPlannerAction.FILE_EXTENSION_LAS) || extension - .equalsIgnoreCase(PedagogicalPlannerAction.FILE_EXTENSION_ZIP))) { + if (!(extension.equalsIgnoreCase(PedagogicalPlannerAction.FILE_EXTENSION_LAS) + || extension.equalsIgnoreCase(PedagogicalPlannerAction.FILE_EXTENSION_ZIP))) { badExtension = true; } } else { badExtension = true; } if (badExtension) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_FILE_BAD_EXTENSION)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_FILE_BAD_EXTENSION)); } } return errors; @@ -1067,8 +1071,8 @@ } else { ActionMessages errors = new ActionMessages(); - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_REMOVE_NODE_TREE)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_REMOVE_NODE_TREE)); saveErrors(request, errors); PedagogicalPlannerAction.log.debug("Unauthorised attempt to removeSequenceNode"); } @@ -1196,8 +1200,8 @@ String nodeContentDir = FileUtil.getFullPath(secureDir, node.getContentFolderId()); if (!FileUtil.isEmptyDirectory(nodeContentDir, true)) { - PedagogicalPlannerAction.log.debug("Create export node content target zip file. File name is " - + targetZipFileName); + PedagogicalPlannerAction.log + .debug("Create export node content target zip file. File name is " + targetZipFileName); ZipFileUtil.createZipFile(targetZipFileName, nodeContentDir, contentDir); } else { PedagogicalPlannerAction.log.debug("No such directory (or empty directory): " + nodeContentDir); @@ -1320,30 +1324,31 @@ learningDesign = getAuthoringService().getLearningDesign(learningDesignID); } catch (ImportToolContentException e) { PedagogicalPlannerAction.log.error(e, e); - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); } if (((learningDesignID == null) || (learningDesignID.longValue() == -1)) && (learningDesignErrorMsgs.size() == 0)) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); return null; } if (learningDesignErrorMsgs.size() > 0) { for (String error : learningDesignErrorMsgs) { PedagogicalPlannerAction.log.error(error); } - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); return null; } if (toolsErrorMsgs.size() > 0) { for (String error : toolsErrorMsgs) { PedagogicalPlannerAction.log.error(error); } - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_TOOL_ERRORS)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_TOOL_ERRORS)); return null; } return learningDesign; @@ -1363,8 +1368,8 @@ properties.put("name", name); properties.put("parentWorkspaceFolder.workspaceFolderId", parentFolder.getWorkspaceFolderId()); properties.put("workspaceFolderType", workspaceFolderType); - List workspaceFolderList = PedagogicalPlannerAction.userManagementService.findByProperties( - WorkspaceFolder.class, properties); + List workspaceFolderList = PedagogicalPlannerAction.userManagementService + .findByProperties(WorkspaceFolder.class, properties); WorkspaceFolder workspaceFolder = null; if ((workspaceFolderList != null) && (workspaceFolderList.size() > 0)) { @@ -1401,8 +1406,8 @@ * @throws RepositoryCheckedException * @throws IOException */ - private void exportSubnodeTemplates(PedagogicalPlannerSequenceNode node, File outputDir) throws IOException, - RepositoryCheckedException, ExportToolContentException { + private void exportSubnodeTemplates(PedagogicalPlannerSequenceNode node, File outputDir) + throws IOException, RepositoryCheckedException, ExportToolContentException { if (node != null) { if (node.getLearningDesignId() == null) { if (node.getSubnodes() != null) { @@ -1414,7 +1419,7 @@ List toolsErrorMsgs = new ArrayList(); String exportedLdFilePath = getExportService().exportLearningDesign(node.getLearningDesignId(), - toolsErrorMsgs, 1, null); + toolsErrorMsgs); if (!toolsErrorMsgs.isEmpty()) { StringBuffer errorMessages = new StringBuffer(); for (String error : toolsErrorMsgs) { @@ -1426,11 +1431,11 @@ File ldIdDir = new File(outputDir, node.getLearningDesignId().toString()); ldIdDir.mkdirs(); - File targetFile = new File(ldIdDir, node.getLearningDesignTitle() - + PedagogicalPlannerAction.FILE_EXTENSION_ZIP); + File targetFile = new File(ldIdDir, + node.getLearningDesignTitle() + PedagogicalPlannerAction.FILE_EXTENSION_ZIP); - PedagogicalPlannerAction.log.debug("Preparing for zipping the template file: " - + node.getLearningDesignTitle()); + PedagogicalPlannerAction.log + .debug("Preparing for zipping the template file: " + node.getLearningDesignTitle()); FileUtils.copyInputStreamToFile(inputStream, targetFile); } } @@ -1481,18 +1486,18 @@ * @throws CorruptIndexException * @throws IOException */ - private Set filterSubnodes(PedagogicalPlannerSequenceNode node, String filterText) throws ParseException, - CorruptIndexException, IOException { + private Set filterSubnodes(PedagogicalPlannerSequenceNode node, String filterText) + throws ParseException, CorruptIndexException, IOException { Set matchingSubnodeUids = new LinkedHashSet(); if (!StringUtils.isEmpty(filterText)) { Set docs = extractSubnodeDocuments(node); if (!docs.isEmpty()) { // Searching is performed in title, brief description and full description of the node. - MultiFieldQueryParser queryParser = new MultiFieldQueryParser(new String[] { - PedagogicalPlannerAction.FIELD_NAME_TITLE, - PedagogicalPlannerAction.FIELD_NAME_FULL_DESCRIPTION, - PedagogicalPlannerAction.FIELD_NAME_BRIEF_DESCRIPTION }, + MultiFieldQueryParser queryParser = new MultiFieldQueryParser( + new String[] { PedagogicalPlannerAction.FIELD_NAME_TITLE, + PedagogicalPlannerAction.FIELD_NAME_FULL_DESCRIPTION, + PedagogicalPlannerAction.FIELD_NAME_BRIEF_DESCRIPTION }, PedagogicalPlannerAction.luceneAnalyzer); Query query = queryParser.parse(filterText); @@ -1552,8 +1557,8 @@ doc.add(fullDescField); } - Field uidField = new StringField(PedagogicalPlannerAction.FIELD_NAME_ANCESTOR_UID, subnode.getUid() - .toString(), Field.Store.YES); + Field uidField = new StringField(PedagogicalPlannerAction.FIELD_NAME_ANCESTOR_UID, + subnode.getUid().toString(), Field.Store.YES); doc.add(uidField); docs.add(doc); @@ -1596,27 +1601,27 @@ Grouping grouping = getAuthoringService().getGroupingById(plannerForm.getToolContentID()); if (grouping.isRandomGrouping()) { RandomGrouping randomGrouping = (RandomGrouping) grouping; - Integer number = StringUtils.isEmpty(plannerForm.getNumberOfGroups()) ? null : Integer - .parseInt(plannerForm.getNumberOfGroups()); + Integer number = StringUtils.isEmpty(plannerForm.getNumberOfGroups()) ? null + : Integer.parseInt(plannerForm.getNumberOfGroups()); randomGrouping.setNumberOfGroups(number); - number = StringUtils.isEmpty(plannerForm.getLearnersPerGroup()) ? null : Integer.parseInt(plannerForm - .getLearnersPerGroup()); + number = StringUtils.isEmpty(plannerForm.getLearnersPerGroup()) ? null + : Integer.parseInt(plannerForm.getLearnersPerGroup()); randomGrouping.setLearnersPerGroup(number); } else if (grouping.isLearnerChoiceGrouping()) { LearnerChoiceGrouping learnerChoiceGrouping = (LearnerChoiceGrouping) grouping; - Integer number = StringUtils.isEmpty(plannerForm.getNumberOfGroups()) ? null : Integer - .parseInt(plannerForm.getNumberOfGroups()); + Integer number = StringUtils.isEmpty(plannerForm.getNumberOfGroups()) ? null + : Integer.parseInt(plannerForm.getNumberOfGroups()); learnerChoiceGrouping.setNumberOfGroups(number); - number = StringUtils.isEmpty(plannerForm.getLearnersPerGroup()) ? null : Integer.parseInt(plannerForm - .getLearnersPerGroup()); + number = StringUtils.isEmpty(plannerForm.getLearnersPerGroup()) ? null + : Integer.parseInt(plannerForm.getLearnersPerGroup()); learnerChoiceGrouping.setLearnersPerGroup(number); learnerChoiceGrouping.setEqualNumberOfLearnersPerGroup(plannerForm.getEqualGroupSizes()); learnerChoiceGrouping.setViewStudentsBeforeSelection(plannerForm.getViewStudentsBeforeSelection()); } else { - Integer number = StringUtils.isEmpty(plannerForm.getNumberOfGroups()) ? null : Integer - .parseInt(plannerForm.getNumberOfGroups()); + Integer number = StringUtils.isEmpty(plannerForm.getNumberOfGroups()) ? null + : Integer.parseInt(plannerForm.getNumberOfGroups()); grouping.setMaxNumberOfGroups(number); } } else { @@ -1625,7 +1630,8 @@ return mapping.findForward(PedagogicalPlannerAction.FORWARD_GROUPING); } - private List getRecentlyModifiedLearnindDesignsAsNodes() throws ServletException { + private List getRecentlyModifiedLearnindDesignsAsNodes() + throws ServletException { // Add the recently modified learning design list, if it's the root node with no filtering User user = getUser(); // the list is sorted most-recently-edited-on-top (so by the timestamp descending) @@ -1745,8 +1751,8 @@ if (activity.isToolActivity()) { activity = getActivityDAO().getActivityByActivityId(activity.getActivityId()); ToolActivity toolActivity = (ToolActivity) activity; - PedagogicalPlannerActivityMetadata plannerMetadata = activitiesMetadata.get(toolActivity - .getToolContentId()); + PedagogicalPlannerActivityMetadata plannerMetadata = activitiesMetadata + .get(toolActivity.getToolContentId()); if (plannerMetadata != null) { PedagogicalPlannerActivityMetadata storedMetadata = toolActivity.getPlannerMetadata(); if (storedMetadata == null) { @@ -1787,7 +1793,7 @@ String zipFilePath = null; boolean valid = false; try { - zipFilePath = getExportService().exportLearningDesign(learningDesignId, toolsErrorMsgs, 1, null); + zipFilePath = getExportService().exportLearningDesign(learningDesignId, toolsErrorMsgs); if (toolsErrorMsgs.isEmpty()) { // get only filename @@ -1813,17 +1819,17 @@ PedagogicalPlannerAction.log.error(e, e); } if (!valid) { - errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( - PedagogicalPlannerAction.ERROR_KEY_EXPORT_TEMPLATE)); + errors.add(ActionMessages.GLOBAL_MESSAGE, + new ActionMessage(PedagogicalPlannerAction.ERROR_KEY_EXPORT_TEMPLATE)); saveErrors(request, errors); for (String error : toolsErrorMsgs) { PedagogicalPlannerAction.log.error(error); } LearningDesign learningDesign = getAuthoringService().getLearningDesign(learningDesignId); errors = openTemplate(request, learningDesign); if (!errors.isEmpty()) { - throw new ServletException(getMessageService().getMessage( - PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); + throw new ServletException(getMessageService() + .getMessage(PedagogicalPlannerAction.ERROR_KEY_LEARNING_DESIGN_COULD_NOT_BE_RETRIEVED)); } return mapping.findForward(PedagogicalPlannerAction.FORWARD_TEMPLATE); } @@ -1967,8 +1973,8 @@ private IExportToolContentService getExportService() { if (PedagogicalPlannerAction.exportService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); PedagogicalPlannerAction.exportService = (IExportToolContentService) ctx .getBean(CentralConstants.EXPORT_TOOLCONTENT_SERVICE_BEAN_NAME); } @@ -1977,8 +1983,8 @@ private IAuthoringService getAuthoringService() { if (PedagogicalPlannerAction.authoringService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); PedagogicalPlannerAction.authoringService = (IAuthoringService) ctx .getBean(AuthoringConstants.AUTHORING_SERVICE_BEAN_NAME); } @@ -1987,8 +1993,8 @@ private IMonitoringService getMonitoringService() { if (PedagogicalPlannerAction.monitoringService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); PedagogicalPlannerAction.monitoringService = (IMonitoringService) ctx .getBean(CentralConstants.MONITORING_SERVICE_BEAN_NAME); } @@ -1997,8 +2003,8 @@ private IUserManagementService getUserManagementService() { if (PedagogicalPlannerAction.userManagementService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); PedagogicalPlannerAction.userManagementService = (IUserManagementService) ctx .getBean(CentralConstants.USER_MANAGEMENT_SERVICE_BEAN_NAME); } @@ -2007,8 +2013,8 @@ private MessageService getMessageService() { if (PedagogicalPlannerAction.messageService == null) { - WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext ctx = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); PedagogicalPlannerAction.messageService = (MessageService) ctx .getBean(CentralConstants.CENTRAL_MESSAGE_SERVICE_BEAN_NAME); } @@ -2017,8 +2023,8 @@ private PedagogicalPlannerDAO getPedagogicalPlannerDAO() { if (PedagogicalPlannerAction.pedagogicalPlannerDAO == null) { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext wac = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); PedagogicalPlannerAction.pedagogicalPlannerDAO = (PedagogicalPlannerDAO) wac .getBean("pedagogicalPlannerDAO"); } @@ -2027,8 +2033,8 @@ private ActivityDAO getActivityDAO() { if (PedagogicalPlannerAction.activityDAO == null) { - WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() - .getServletContext()); + WebApplicationContext wac = WebApplicationContextUtils + .getRequiredWebApplicationContext(getServlet().getServletContext()); PedagogicalPlannerAction.activityDAO = (ActivityDAO) wac.getBean("activityDAO"); } return PedagogicalPlannerAction.activityDAO; Index: lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LearningDesignRepositoryServlet.java =================================================================== diff -u -r26b52cfb94f532a22ad472ac2def2fcc97b1380e -r078ffcc5cce6214e179857ace04486fa04a7e3a2 --- lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LearningDesignRepositoryServlet.java (.../LearningDesignRepositoryServlet.java) (revision 26b52cfb94f532a22ad472ac2def2fcc97b1380e) +++ lams_central/src/java/org/lamsfoundation/lams/webservice/xml/LearningDesignRepositoryServlet.java (.../LearningDesignRepositoryServlet.java) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) @@ -1,7 +1,6 @@ package org.lamsfoundation.lams.webservice.xml; import java.io.BufferedInputStream; -import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -69,9 +68,6 @@ private static IExportToolContentService exportToolContentService = null; private static final String PARAM_LEARING_DESIGN_ID = "learningDesignID"; - private static final String PARAM_EXPORT_FORMAT = "format"; - private static final String IMS_XSLT_NAME = "learning-design-ims.xslt"; - private static final String IMS_XSLT_PATH = "/toolcontent"; /** * Constructor of the object. @@ -83,6 +79,7 @@ /** * Destruction of the servlet.
*/ + @Override public void destroy() { super.destroy(); // Just puts "destroy" string in log // Put your code here @@ -125,12 +122,11 @@ } /** - * the format should be something like this: [ ['My Workspace', null, - * ['Mary Morgan Folder', null, ['3 activity sequence','1024'] ], - * ['Organisations', null, ['Developers Playpen', null, ['Lesson - * Sequence Folder', null, ['',null] ] ], ['MATH111', null, ['Lesson - * Sequence Folder', null, ['',null] ] ] ] ] ] + * the format should be something like this: [ ['My Workspace', null, ['Mary Morgan Folder', null, ['3 activity + * sequence','1024'] ], ['Organisations', null, ['Developers Playpen', null, ['Lesson Sequence Folder', null, + * ['',null] ] ], ['MATH111', null, ['Lesson Sequence Folder', null, ['',null] ] ] ] ] ] */ + @Override public String toString() { // return '[' + convert() + ']'; @@ -166,8 +162,8 @@ sb.append(']'); } else if (content.getResourceType().equals(FolderContentDTO.DESIGN)) { sb.append('['); - sb.append('\'').append(content.getName()).append('\'').append(',').append('\'').append( - content.getResourceID()).append('\''); + sb.append('\'').append(content.getName()).append('\'').append(',').append('\'') + .append(content.getResourceID()).append('\''); sb.append(']'); } return sb.toString(); @@ -216,34 +212,36 @@ } } - private ContentTreeNode buildContentTree(Integer userId, Integer mode) throws IOException, - UserAccessDeniedException, RepositoryCheckedException { - log.debug("User Id - " + userId); - FolderContentDTO rootFolder = new FolderContentDTO(msgService.getMessage("label.workspace.root_folder"), - msgService.getMessage("folder"), null, null, FolderContentDTO.FOLDER, + private ContentTreeNode buildContentTree(Integer userId, Integer mode) + throws IOException, UserAccessDeniedException, RepositoryCheckedException { + LearningDesignRepositoryServlet.log.debug("User Id - " + userId); + FolderContentDTO rootFolder = new FolderContentDTO( + LearningDesignRepositoryServlet.msgService.getMessage("label.workspace.root_folder"), + LearningDesignRepositoryServlet.msgService.getMessage("folder"), null, null, FolderContentDTO.FOLDER, WorkspaceAction.BOOTSTRAP_FOLDER_ID.longValue(), WorkspaceFolder.READ_ACCESS, null); ContentTreeNode root = new ContentTreeNode(rootFolder); - FolderContentDTO userFolder = service.getUserWorkspaceFolder(userId); + FolderContentDTO userFolder = LearningDesignRepositoryServlet.service.getUserWorkspaceFolder(userId); root.addChild(buildContentTreeNode(userFolder, userId, mode)); - - FolderContentDTO dummyOrgFolder = new FolderContentDTO(msgService.getMessage("organisations"), msgService - .getMessage("folder"), null, null, FolderContentDTO.FOLDER, new Long(WorkspaceAction.ORG_FOLDER_ID - .longValue()), WorkspaceFolder.READ_ACCESS, null); + + FolderContentDTO dummyOrgFolder = new FolderContentDTO( + LearningDesignRepositoryServlet.msgService.getMessage("organisations"), + LearningDesignRepositoryServlet.msgService.getMessage("folder"), null, null, FolderContentDTO.FOLDER, + new Long(WorkspaceAction.ORG_FOLDER_ID.longValue()), WorkspaceFolder.READ_ACCESS, null); ContentTreeNode dummyOrgNode = new ContentTreeNode(dummyOrgFolder); // tried using service.getAccessibleOrganisationWorkspaceFolders(userId) // api, // but it doesn't work, the userOrganisations set of the user // got from workspaceManagementService with the userId supplied is // empty, which // is not true. - Vector orgFolders = service.getAccessibleOrganisationWorkspaceFolders(userId); + Vector orgFolders = LearningDesignRepositoryServlet.service.getAccessibleOrganisationWorkspaceFolders(userId); for (int i = 0; i < orgFolders.size(); i++) { FolderContentDTO orgFolder = (FolderContentDTO) orgFolders.get(i); dummyOrgNode.addChild(buildContentTreeNode(orgFolder, userId, mode)); } root.addChild(dummyOrgNode); - - FolderContentDTO publicFolder = service.getPublicWorkspaceFolder(userId); + + FolderContentDTO publicFolder = LearningDesignRepositoryServlet.service.getPublicWorkspaceFolder(userId); if (publicFolder != null) { root.addChild(buildContentTreeNode(publicFolder, userId, mode)); } @@ -252,12 +250,13 @@ private ContentTreeNode buildContentTreeNode(FolderContentDTO folder, Integer userId, Integer mode) throws UserAccessDeniedException, RepositoryCheckedException { - log.debug("build content tree node for folder - " + folder.getName()); + LearningDesignRepositoryServlet.log.debug("build content tree node for folder - " + folder.getName()); ContentTreeNode node = new ContentTreeNode(folder); if (folder.getResourceType().equals(FolderContentDTO.FOLDER)) { - log.debug(folder.getName() + " is a folder"); - WorkspaceFolder wsfolder = service.getWorkspaceFolder(folder.getResourceID().intValue()); - Vector items = service.getFolderContentsExcludeHome(userId, wsfolder, mode); + LearningDesignRepositoryServlet.log.debug(folder.getName() + " is a folder"); + WorkspaceFolder wsfolder = LearningDesignRepositoryServlet.service + .getWorkspaceFolder(folder.getResourceID().intValue()); + Vector items = LearningDesignRepositoryServlet.service.getFolderContentsExcludeHome(userId, wsfolder, mode); for (int i = 0; i < items.size(); i++) { FolderContentDTO content = (FolderContentDTO) items.get(i); node.addChild(buildContentTreeNode(content, userId, mode)); @@ -272,14 +271,15 @@ * This method is called when a form has its tag value method equals to get. * * @param request - * the request send by the client to the server + * the request send by the client to the server * @param response - * the response send by the server to the client + * the response send by the server to the client * @throws ServletException - * if an error occurred + * if an error occurred * @throws IOException - * if an error occurred + * if an error occurred */ + @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { @@ -296,111 +296,123 @@ String method = request.getParameter(CentralConstants.PARAM_METHOD); String usePrefix = request.getParameter(CentralConstants.PARAM_USE_PREFIX); final boolean isUpdateUserDetails = false; - + String firstName = request.getParameter(LoginRequestDispatcher.PARAM_FIRST_NAME); String lastName = request.getParameter(LoginRequestDispatcher.PARAM_LAST_NAME); String email = request.getParameter(LoginRequestDispatcher.PARAM_EMAIL); - - if (serverId == null || datetime == null || hashValue == null || username == null || courseId == null - || country == null || lang == null ) { + + if ((serverId == null) || (datetime == null) || (hashValue == null) || (username == null) + || (courseId == null) || (country == null) || (lang == null)) { String msg = "Parameters missing"; - log.error(msg); - response.sendError(response.SC_BAD_REQUEST, "Parameters missing"); + LearningDesignRepositoryServlet.log.error(msg); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameters missing"); } - + // LDEV-2196 preserve character encoding if necessary if (request.getCharacterEncoding() == null) { - log.debug("request.getCharacterEncoding is empty, parsing username and courseName as 8859_1 to UTF-8..."); - username = new String(username.getBytes("8859_1"), "UTF-8"); - if (courseName != null) { - courseName = new String(courseName.getBytes("8859_1"), "UTF-8"); - } + LearningDesignRepositoryServlet.log.debug( + "request.getCharacterEncoding is empty, parsing username and courseName as 8859_1 to UTF-8..."); + username = new String(username.getBytes("8859_1"), "UTF-8"); + if (courseName != null) { + courseName = new String(courseName.getBytes("8859_1"), "UTF-8"); + } } // get Server map - ExtServerOrgMap serverMap = integrationService.getExtServerOrgMap(serverId); + ExtServerOrgMap serverMap = LearningDesignRepositoryServlet.integrationService.getExtServerOrgMap(serverId); // authenticate Authenticator.authenticate(serverMap, datetime, username, hashValue); // get user map, user is created if this is their first use - if (method != null && method.equals("exportLD")) { + if ((method != null) && method.equals("exportLD")) { // do export exportLD(request, response); - - } else if (method != null && ( method.equals("getLearningDesignsJSON") || method.equals("getPagedHomeLearningDesignsJSON")) ) { - Integer userId = getUserId(username, courseId, courseName, country, lang, usePrefix, + } else if ((method != null) + && (method.equals("getLearningDesignsJSON") || method.equals("getPagedHomeLearningDesignsJSON"))) { + + Integer userId = getUserId(username, courseId, courseName, country, lang, usePrefix, isUpdateUserDetails, firstName, lastName, email, serverMap); - - boolean allowInvalidDesigns = WebUtil.readBooleanParam(request, "allowInvalidDesigns", false); - - String folderContentsJSON = null; - if ( method.equals("getLearningDesignsJSON") ) { - Integer folderID = WebUtil.readIntParam(request, "folderID", true); - String designType = request.getParameter("type"); - folderContentsJSON = service.getFolderContentsJSON(folderID, userId, allowInvalidDesigns, designType); - } else { - Integer page = WebUtil.readIntParam(request, "page", true); - Integer size = WebUtil.readIntParam(request, "size", true); - String sortName = request.getParameter("sortName"); - String sortDate = request.getParameter("sortDate"); - String search = request.getParameter("search"); - folderContentsJSON = service.getPagedLearningDesignsJSON(userId, allowInvalidDesigns, search, page, size, - sortName == null ? null : ( sortName.equals("0") ? "DESC" : "ASC" ), - sortDate == null ? null : ( sortDate.equals("0") ? "DESC" : "ASC" )); - } - log.debug("LearningDesignRepositoryServlet returning "+folderContentsJSON); - - response.setContentType("application/json;charset=UTF-8"); - response.getWriter().write(folderContentsJSON); + boolean allowInvalidDesigns = WebUtil.readBooleanParam(request, "allowInvalidDesigns", false); - } else if (method != null && method.equals("deleteLearningDesignJSON") ) { - + String folderContentsJSON = null; + if (method.equals("getLearningDesignsJSON")) { + Integer folderID = WebUtil.readIntParam(request, "folderID", true); + String designType = request.getParameter("type"); + folderContentsJSON = LearningDesignRepositoryServlet.service.getFolderContentsJSON(folderID, userId, + allowInvalidDesigns, designType); + } else { + Integer page = WebUtil.readIntParam(request, "page", true); + Integer size = WebUtil.readIntParam(request, "size", true); + String sortName = request.getParameter("sortName"); + String sortDate = request.getParameter("sortDate"); + String search = request.getParameter("search"); + folderContentsJSON = LearningDesignRepositoryServlet.service.getPagedLearningDesignsJSON(userId, + allowInvalidDesigns, search, page, size, + sortName == null ? null : (sortName.equals("0") ? "DESC" : "ASC"), + sortDate == null ? null : (sortDate.equals("0") ? "DESC" : "ASC")); + } + + LearningDesignRepositoryServlet.log + .debug("LearningDesignRepositoryServlet returning " + folderContentsJSON); + + response.setContentType("application/json;charset=UTF-8"); + response.getWriter().write(folderContentsJSON); + + } else if ((method != null) && method.equals("deleteLearningDesignJSON")) { + Integer userId = getUserId(username, courseId, courseName, country, lang, usePrefix, isUpdateUserDetails, firstName, lastName, email, serverMap); - - Long learningDesignId = WebUtil.readLongParam(request, PARAM_LEARING_DESIGN_ID); - log.debug("User "+userId+" "+username+" deleting learning design "+learningDesignId); - String wddxResponse = service.deleteResource(learningDesignId, FolderContentDTO.DESIGN, userId); + + Long learningDesignId = WebUtil.readLongParam(request, + LearningDesignRepositoryServlet.PARAM_LEARING_DESIGN_ID); + LearningDesignRepositoryServlet.log + .debug("User " + userId + " " + username + " deleting learning design " + learningDesignId); + String wddxResponse = LearningDesignRepositoryServlet.service.deleteResource(learningDesignId, + FolderContentDTO.DESIGN, userId); Hashtable table = (Hashtable) WDDXProcessor.deserialize(wddxResponse); - log.debug("Delete response "+wddxResponse); + LearningDesignRepositoryServlet.log.debug("Delete response " + wddxResponse); Double messageTypeDouble = (Double) table.get("messageType"); int messageType = messageTypeDouble != null ? messageTypeDouble.intValue() : 0; - if ( messageType == FlashMessage.OBJECT_MESSAGE ) { + if (messageType == FlashMessage.OBJECT_MESSAGE) { JSONObject jsonObject = new JSONObject(table); response.setContentType("application/json;charset=utf-8"); response.getWriter().print(jsonObject.toString()); } else { - log.error("Unable to delete learning design "+learningDesignId+" for user "+userId+" error "+table.get("messageValue")); - response.sendError(response.SC_INTERNAL_SERVER_ERROR, table.get("messageValue").toString()); + LearningDesignRepositoryServlet.log.error("Unable to delete learning design " + learningDesignId + + " for user " + userId + " error " + table.get("messageValue")); + response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, + table.get("messageValue").toString()); } - //TODO remove the next else-paragraph as soon as all integrations will start using new method. (After this also stop checking for (method != null && method.equals("getLearningDesignsJSONFormat"))) + //TODO remove the next else-paragraph as soon as all integrations will start using new method. (After this also stop checking for (method != null && method.equals("getLearningDesignsJSONFormat"))) } else { - if ( mode == null) { + if (mode == null) { String msg = "Parameter missing: mode"; - log.error(msg); - response.sendError(response.SC_BAD_REQUEST, msg); + LearningDesignRepositoryServlet.log.error(msg); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, msg); } ExtUserUseridMap userMap = null; boolean prefix = usePrefix == null ? true : Boolean.parseBoolean(usePrefix); - if (firstName == null && lastName == null) { - userMap = integrationService.getExtUserUseridMap(serverMap, username, prefix); + if ((firstName == null) && (lastName == null)) { + userMap = LearningDesignRepositoryServlet.integrationService.getExtUserUseridMap(serverMap, + username, prefix); } else { - userMap = integrationService.getImplicitExtUserUseridMap(serverMap, username, firstName, lastName, - lang, country, email, prefix, isUpdateUserDetails); + userMap = LearningDesignRepositoryServlet.integrationService.getImplicitExtUserUseridMap(serverMap, + username, firstName, lastName, lang, country, email, prefix, isUpdateUserDetails); } // create group for external course if necessary - integrationService.getExtCourseClassMap(serverMap, userMap, courseId, country, lang, courseName, LoginRequestDispatcher.METHOD_AUTHOR); + LearningDesignRepositoryServlet.integrationService.getExtCourseClassMap(serverMap, userMap, courseId, + country, lang, courseName, LoginRequestDispatcher.METHOD_AUTHOR); Integer userId = userMap.getUser().getUserId(); String contentTree = buildContentTree(userId, mode).toString(); @@ -414,23 +426,24 @@ } } catch (NumberFormatException nfe) { - log.error("mode is not an integer", nfe); - response.sendError(response.SC_BAD_REQUEST, "mode is not an integer"); + LearningDesignRepositoryServlet.log.error("mode is not an integer", nfe); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "mode is not an integer"); } catch (AuthenticationException e) { - log.error("can not authenticate", e); - response.sendError(response.SC_BAD_REQUEST, "can not authenticate"); + LearningDesignRepositoryServlet.log.error("can not authenticate", e); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "can not authenticate"); } catch (UserInfoFetchException e) { - log.error("can not retrieve user information", e); - response.sendError(response.SC_BAD_REQUEST, "can not retrieve user information"); + LearningDesignRepositoryServlet.log.error("can not retrieve user information", e); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "can not retrieve user information"); } catch (UserAccessDeniedException e) { - log.error("user access denied", e); - response.sendError(response.SC_BAD_REQUEST, "user access denied"); + LearningDesignRepositoryServlet.log.error("user access denied", e); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "user access denied"); } catch (RepositoryCheckedException e) { - log.error("repository checked", e); - response.sendError(response.SC_BAD_REQUEST, "repository checked"); + LearningDesignRepositoryServlet.log.error("repository checked", e); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, "repository checked"); } catch (Exception e) { - log.error("Problem with LearningDesignRepositoryServlet request", e); - response.sendError(response.SC_BAD_REQUEST, "Problem with LearningDesignRepositoryServlet request"); + LearningDesignRepositoryServlet.log.error("Problem with LearningDesignRepositoryServlet request", e); + response.sendError(HttpServletResponse.SC_BAD_REQUEST, + "Problem with LearningDesignRepositoryServlet request"); } } @@ -440,32 +453,33 @@ ExtServerOrgMap serverMap) throws UserInfoFetchException, UserInfoValidationException { ExtUserUseridMap userMap = null; boolean prefix = usePrefix == null ? true : Boolean.parseBoolean(usePrefix); - if (firstName == null && lastName == null) { - userMap = integrationService.getExtUserUseridMap(serverMap, username, prefix); + if ((firstName == null) && (lastName == null)) { + userMap = LearningDesignRepositoryServlet.integrationService.getExtUserUseridMap(serverMap, username, + prefix); } else { - userMap = integrationService.getImplicitExtUserUseridMap(serverMap, username, firstName, lastName, - lang, country, email, prefix, isUpdateUserDetails); + userMap = LearningDesignRepositoryServlet.integrationService.getImplicitExtUserUseridMap(serverMap, + username, firstName, lastName, lang, country, email, prefix, isUpdateUserDetails); } - + // create group for external course if necessary - integrationService.getExtCourseClassMap(serverMap, userMap, courseId, country, lang, courseName, LoginRequestDispatcher.METHOD_AUTHOR); + LearningDesignRepositoryServlet.integrationService.getExtCourseClassMap(serverMap, userMap, courseId, country, + lang, courseName, LoginRequestDispatcher.METHOD_AUTHOR); Integer userId = userMap.getUser().getUserId(); return userId; } - + + @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - doGet(request, response); + doGet(request, response); } public void exportLD(HttpServletRequest request, HttpServletResponse response) { - Long learningDesignId = WebUtil.readLongParam(request, PARAM_LEARING_DESIGN_ID); - int format = WebUtil.readIntParam(request, PARAM_EXPORT_FORMAT); + Long learningDesignId = WebUtil.readLongParam(request, LearningDesignRepositoryServlet.PARAM_LEARING_DESIGN_ID); List toolsErrorMsgs = new ArrayList(); try { - File xslt = new File(getServletContext().getRealPath(IMS_XSLT_PATH) + File.separator + IMS_XSLT_NAME); - String zipFilename = exportToolContentService.exportLearningDesign(learningDesignId, toolsErrorMsgs, - format, xslt); + String zipFilename = LearningDesignRepositoryServlet.exportToolContentService + .exportLearningDesign(learningDesignId, toolsErrorMsgs); // get only filename String zipfile = FileUtil.getFileName(zipFilename); @@ -475,7 +489,7 @@ // Different browsers handle stream downloads differently LDEV-1243 String filename = FileUtil.encodeFilenameForDownload(request, zipfile); - log.debug("Final filename to export: " + filename); + LearningDesignRepositoryServlet.log.debug("Final filename to export: " + filename); response.setContentType("application/x-download"); // response.setContentType("application/zip"); @@ -492,43 +506,48 @@ out.write((char) ch); count++; } - log.debug("Wrote out " + count + " bytes"); + LearningDesignRepositoryServlet.log.debug("Wrote out " + count + " bytes"); response.setContentLength(count); out.flush(); } catch (Exception e) { - log.error("Exception occured writing out file:" + e.getMessage()); + LearningDesignRepositoryServlet.log.error("Exception occured writing out file:" + e.getMessage()); throw new ExportToolContentException(e); } finally { try { - if (in != null) + if (in != null) { in.close(); // very important - if (out != null) + } + if (out != null) { out.close(); + } } catch (Exception e) { - log.error("Error Closing file. File already written out - no exception being thrown.", e); + LearningDesignRepositoryServlet.log + .error("Error Closing file. File already written out - no exception being thrown.", e); } } } catch (Exception e1) { - log.error("Unable to export tool content to external integrated server: " + e1.toString()); + LearningDesignRepositoryServlet.log + .error("Unable to export tool content to external integrated server: " + e1.toString()); } } /** * Initialization of the servlet.
* * @throws ServletException - * if an error occure + * if an error occure */ + @Override public void init() throws ServletException { - integrationService = (IntegrationService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("integrationService"); + LearningDesignRepositoryServlet.integrationService = (IntegrationService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("integrationService"); - service = (IWorkspaceManagementService) WebApplicationContextUtils.getRequiredWebApplicationContext( - getServletContext()).getBean("workspaceManagementService"); + LearningDesignRepositoryServlet.service = (IWorkspaceManagementService) WebApplicationContextUtils + .getRequiredWebApplicationContext(getServletContext()).getBean("workspaceManagementService"); - msgService = service.getMessageService(); + LearningDesignRepositoryServlet.msgService = LearningDesignRepositoryServlet.service.getMessageService(); - exportToolContentService = (IExportToolContentService) WebApplicationContextUtils + LearningDesignRepositoryServlet.exportToolContentService = (IExportToolContentService) WebApplicationContextUtils .getRequiredWebApplicationContext(getServletContext()).getBean("exportToolContentService"); } } Index: lams_central/web/authoring/authoring.jsp =================================================================== diff -u -r07865c855b32c77613ed72dd81cd499033dca4dd -r078ffcc5cce6214e179857ace04486fa04a7e3a2 --- lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision 07865c855b32c77613ed72dd81cd499033dca4dd) +++ lams_central/web/authoring/authoring.jsp (.../authoring.jsp) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) @@ -319,9 +319,6 @@
  • -
  • Index: lams_central/web/includes/javascript/authoring/authoringMenu.js =================================================================== diff -u -r07865c855b32c77613ed72dd81cd499033dca4dd -r078ffcc5cce6214e179857ace04486fa04a7e3a2 --- lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision 07865c855b32c77613ed72dd81cd499033dca4dd) +++ lams_central/web/includes/javascript/authoring/authoringMenu.js (.../authoringMenu.js) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) @@ -325,13 +325,13 @@ /** * Opens a pop up for exporting LD. */ - exportLearningDesign : function(format){ + exportLearningDesign : function(){ if (layout.modified || layout.activities.length == 0) { return; } $('iframe', layout.exportLDDialog) - .attr('src', LAMS_URL + 'authoring/exportToolContent.do?method=export&format=' + format + '&learningDesignID=' + .attr('src', LAMS_URL + 'authoring/exportToolContent.do?method=export&learningDesignID=' + layout.ld.learningDesignID); layout.exportLDDialog.dialog('open'); }, Fisheye: Tag 078ffcc5cce6214e179857ace04486fa04a7e3a2 refers to a dead (removed) revision in file `lams_central/web/toolcontent/IMS_LD_Level_A.xsd'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 078ffcc5cce6214e179857ace04486fa04a7e3a2 refers to a dead (removed) revision in file `lams_central/web/toolcontent/IMS_LD_Level_B.xsd'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 078ffcc5cce6214e179857ace04486fa04a7e3a2 refers to a dead (removed) revision in file `lams_central/web/toolcontent/IMS_LD_Level_C.xsd'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_central/web/toolcontent/import.jsp =================================================================== diff -u -r4563572ef748ba3e8729982d47ab671d561f081d -r078ffcc5cce6214e179857ace04486fa04a7e3a2 --- lams_central/web/toolcontent/import.jsp (.../import.jsp) (revision 4563572ef748ba3e8729982d47ab671d561f081d) +++ lams_central/web/toolcontent/import.jsp (.../import.jsp) (revision 078ffcc5cce6214e179857ace04486fa04a7e3a2) @@ -3,12 +3,13 @@ <%@ taglib uri="tags-core" prefix="c"%> <%@ taglib uri="tags-fmt" prefix="fmt"%> - + <fmt:message key="title.import" /> - + +