Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java =================================================================== diff -u -r2ac039eeb6b49f34b1782fed80e7b7a637eaf6ad -r0623b98762a0369d9e99c7843075d3a9b161348d --- lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 2ac039eeb6b49f34b1782fed80e7b7a637eaf6ad) +++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/service/ExportToolContentService.java (.../ExportToolContentService.java) (revision 0623b98762a0369d9e99c7843075d3a9b161348d) @@ -154,80 +154,133 @@ private static final int PACKAGE_FORMAT_IMS = 2; public static final String LEARNING_DESIGN_SERVICE_BEAN_NAME = "learningDesignService"; + public static final String MESSAGE_SERVICE_BEAN_NAME = "commonMessageService"; + public static final String LD102IMPORTER_BEAN_NAME = "ld102Importer"; // export tool content zip file prefix public static final String EXPORT_TOOLCONTNET_ZIP_PREFIX = "lams_toolcontent_"; + public static final String EXPORT_LDCONTENT_ZIP_PREFIX = "lams_ldcontent_"; + public static final String EXPORT_TOOLCONTNET_FOLDER_SUFFIX = "export_toolcontent"; + public static final String EXPORT_TOOLCONTNET_ZIP_SUFFIX = ".zip"; + public static final String EXPORT_LDCONTENT_ZIP_SUFFIX = ".zip"; + public static final String LEARNING_DESIGN_FILE_NAME = "learning_design.xml"; + private static final String LEARNING_DESIGN_IMS_FILE_NAME = "imsmanifest.xml"; + public static final String TOOL_FILE_NAME = "tool.xml"; + public static final String TOOL_FAILED_FILE_NAME = "export_failed.xml"; private static final String ERROR_TOOL_NOT_FOUND = "error.import.matching.tool.not.found"; + private static final String ERROR_SERVICE_ERROR = "error.import.tool.service.fail"; + private static final String ERROR_NO_VALID_TOOL = "error.no.valid.tool"; + private static final String ERROR_INCOMPATIBLE_VERSION = "error.possibly.incompatible.version"; + private static final String FILTER_METHOD_PREFIX_DOWN = "down"; + private static final String FILTER_METHOD_PREFIX_UP = "up"; + private static final String FILTER_METHOD_MIDDLE = "To"; // LAMS export format tag names private static final String LAMS_VERSION = "version"; + private static final String LAMS_TITLE = "title"; // IMS format some tag name private static final String IMS_FILE_NAME_EXT = "_imsld"; + private static final String IMS_TAG_RESOURCES = "resources"; + private static final String IMS_TAG_RESOURCE = "resource"; + private static final String IMS_ATTR_IDENTIFIER = "identifier"; + private static final String IMS_TAG_FILE = "file"; + private static final String IMS_ATTR_HREF = "href"; + private static final String IMS_ATTR_REF = "ref"; + private static final String IMS_TAG_PROPERTIES = "properties"; + private static final String IMS_TAG_LOCPERS_PROPERTY = "locpers-property"; + private static final String IMS_TAG_DATATYPE = "datatype"; + private static final String IMS_ATTR_DATATYPE = "datatype"; + private static final String IMS_TAG_INITIAL_VALUE = "initial-value"; + private static final String IMS_TAG_CONDITIONS = "conditions"; + private static final String IMS_TAG_IF = "if"; + private static final String IMS_TAG_THEN = "then"; + private static final String IMS_TAG_ELSE = "else"; + private static final String IMS_TAG_IS = "is"; + private static final String IMS_TAG_SHOW = "show"; + private static final String IMS_TAG_HIDE = "hide"; + private static final String IMS_TAG_PROPERTY_REF = "property-ref"; + private static final String IMS_TAG_PROPERTY_VALUE = "property-value"; private static final String IMS_PREFIX_RESOURCE_IDENTIFIER = "R-"; + private static final String IMS_PREFIX_ACTIVITY_REF = "A-"; + private static final String IMS_PREFIX_COMPLEX_REF = "S-"; + private static final String IMS_PREFIX_PROPERTY_REF = "P-"; - // this is not IMS standard tag, temporarily use to gather all tools node list + // this is not IMS standard tag, temporarily use to gather all tools + // node list private static final String IMS_TAG_TRANSITIONS = "transitions"; - // this is not IMS standard tag, term used to ref grouping/gate activities + // this is not IMS standard tag, term used to ref grouping/gate + // activities private static final String IMS_TAG_GROUPING = "group"; + private static final String IMS_TAG_GATE = "gate"; private static final String IMS_TAG_OPTIONAL = "SELECTION"; + private static final String IMS_TAG_PARALLEL = "PARALLEL"; + private static final String IMS_TAG_SEQUENCE = "SEQUENCE"; + private static final String IMS_TAG_BRANCHING = "BRANCHING"; // temporarily file for IMS XSLT file private static final String XSLT_PARAM_RESOURCE_FILE = "resourcesFile"; + private static final String IMS_RESOURCES_FILE_NAME = "resources.xml"; + private static final String XSLT_PARAM_TRANSITION_FILE = "transitionsFile"; + private static final String IMS_TRANSITION_FILE_NAME = "transitions.xml"; + private static final String XSLT_PARAM_PROPERTIES_FILE = "propertiesFile"; + private static final String IMS_PROPERTIES_FILE_NAME = "properties.xml"; + private static final String XSLT_PARAM_CONDITIONS_FILE = "conditionsFile"; + private static final String IMS_CONDITIONS_FILE_NAME = "conditions.xml"; private static final String IMS_TOOL_NS_PREFIX = "http://www.lamsfoundation/xsd/lams_tool_"; @@ -238,52 +291,77 @@ // 2 dirs for zip file and temporary IMS XSLT private static final String DIR_CONTENT = "content"; + private static final String DIR_XSLT_TEMP = "xslttmp"; // files name of IMS SCHEMA private static final String SCHEMA_FILE_IMSCP = "imscp_v1p1.xsd"; + private static final String SCHEMA_FILE_IMS_LD_LEVEL_A = "IMS_LD_Level_A.xsd"; + private static final String SCHEMA_FILE_IMS_LD_LEVEL_B = "IMS_LD_Level_B.xsd"; + private static final String SCHEMA_FILE_IMS_LD_LEVEL_C = "IMS_LD_Level_C.xsd"; // Other fields private Logger log = Logger.getLogger(ExportToolContentService.class); private static MessageService messageService; + private ApplicationContext applicationContext; - // save list of all tool file node class information. One tool may have over one file node, such as - // in share resource tool, it has contnent attachment and shared resource item attachement. + // save list of all tool file node class information. One tool may have + // over one file node, such as + // in share resource tool, it has contnent attachment and shared + // resource item attachement. private List fileHandleClassList; + private Class filterClass; // spring injection properties private IActivityDAO activityDAO; + private IToolDAO toolDAO; + private IToolContentDAO toolContentDAO; + private ISystemToolDAO systemToolDAO; + private IBaseDAO baseDAO; + private ILicenseDAO licenseDAO; + private IGroupingDAO groupingDAO; + private ITransitionDAO transitionDAO; + private ILearningDesignDAO learningDesignDAO; + private ILearningLibraryDAO learningLibraryDAO; + private IToolImportSupportDAO toolImportSupportDAO; private static final String KEY_MSG_IMPORT_FILE_FORMAT = "msg.import.file.format"; /** - * Class of tool attachment file handler class and relative fields information container. + * Class of tool attachment file handler class and relative fields + * information container. */ private class NameInfo { // the Class instance according to className. public String className; + public String uuidFieldName; + public String versionFieldName; + public String fileNameFieldName; + public String mimeTypeFieldName; + public String filePropertyFieldName; + public String initalItemFieldName; public NameInfo(String className, String uuidFieldName, String versionFieldName) { @@ -310,10 +388,12 @@ private class ValueInfo { // for unmarshal public NameInfo name; + public Object instance; // for marshal public Long fileUuid; + public Long fileVersionId; public ValueInfo(NameInfo name, Object instance) { @@ -334,7 +414,9 @@ private class FileInvocationHandler implements InvocationHandler { private Object obj; + private List fileNodes; + private List fileHandleClassList; public FileInvocationHandler(Object obj) { @@ -380,7 +462,8 @@ // for import : unmarshal xml to object if (StringUtils.equals(method.getName(), "unmarshal") && result != null) { - // During deserialize XML file into object, it will save file node into fileNodes + // During deserialize XML file into object, it will save + // file node into fileNodes for (NameInfo name : fileHandleClassList) { if (name.className.equals(result.getClass().getName())) { fileNodes.add(ExportToolContentService.this.new ValueInfo(name, result)); @@ -409,8 +492,8 @@ } /** - * This class is just for later system extent tool compaiblity strategy use. Currently, it just simple to get tool - * by same signature. + * This class is just for later system extent tool compaiblity strategy + * use. Currently, it just simple to get tool by same signature. * * @author Steve.Ni * @@ -441,11 +524,14 @@ String contentDir = FileUtil.getFullPath(rootDir, ExportToolContentService.DIR_CONTENT); FileUtil.createDirectory(contentDir); - // this folder put all IMS XSLT transform temporary files, so try to keep content is clean for final + // this folder put all IMS XSLT transform temporary files, so + // try to keep content is clean for final // package! - // The reason use temporary folder instead of delete temporary files from content folder is, sometimes, + // The reason use temporary folder instead of delete temporary + // files from content folder is, sometimes, // delete file does not work well - // this makes the final zip file should contain some rubbish files. + // this makes the final zip file should contain some rubbish + // files. String xsltTempDir = FileUtil.getFullPath(rootDir, ExportToolContentService.DIR_XSLT_TEMP); if (format == ExportToolContentService.PACKAGE_FORMAT_IMS) { FileUtil.createDirectory(xsltTempDir); @@ -459,7 +545,8 @@ } Writer ldFile = new OutputStreamWriter(new FileOutputStream(ldFileName), "UTF-8"); - // get learning desing and serialize it to XML file. Update the version to reflect the + // get learning desing and serialize it to XML file. Update the + // version to reflect the // version now, rather than the version when it was saved. ILearningDesignService service = getLearningDesignService(); LearningDesignDTO ldDto = service.getLearningDesignDTO(learningDesignId, ""); @@ -470,26 +557,32 @@ } /* - * learning design DTO is ready to be written into XML, but we need to find out which groupings and - * branching mappings are not supposed to be included into the structure (LDEV-1825) - */ + * learning design DTO is ready to be written into XML, but we + * need to find out which groupings and branching mappings are + * not supposed to be included into the structure (LDEV-1825) + */ Set groupingsToSkip = new TreeSet(); - // for these branching activities there will be no branching mappings saved into XML, since they will be + // for these branching activities there will be no branching + // mappings saved into XML, since they will be // recreated in monitoring Set branchingActivitiesToSkip = new TreeSet(); - // iterator all activities in this learning design and export their content to given folder. - // The content will contain tool.xml and attachment files of tools from LAMS repository. + // iterator all activities in this learning design and export + // their content to given folder. + // The content will contain tool.xml and attachment files of + // tools from LAMS repository. List activities = ldDto.getActivities(); // create resources Dom node list for IMS package. List resChildren = new ArrayList(); - // iterator all activities and export tool.xml and its attachments + // iterator all activities and export tool.xml and its + // attachments for (AuthoringActivityDTO activity : activities) { int activityTypeID = activity.getActivityTypeID().intValue(); - // for teacher chosen and tool based branching activities there should be no groupings saved to XML + // for teacher chosen and tool based branching activities there + // should be no groupings saved to XML if (activityTypeID == Activity.CHOSEN_BRANCHING_ACTIVITY_TYPE || activityTypeID == Activity.TOOL_BRANCHING_ACTIVITY_TYPE) { Long groupingID = activity.getGroupingID(); @@ -501,7 +594,8 @@ activity.setGroupingUIID(null); continue; } - // for group based define later branching activities there should be no branching mappings saved to XML + // for group based define later branching activities there + // should be no branching mappings saved to XML if (activityTypeID == Activity.GROUP_BRANCHING_ACTIVITY_TYPE && activity.getDefineLater()) { branchingActivitiesToSkip.add(activity.getActivityUIID()); } @@ -510,7 +604,8 @@ continue; } - // find out current acitivites toolContentMananger and export tool content. + // find out current acitivites toolContentMananger and export + // tool content. ToolContentManager contentManager = (ToolContentManager) findToolService(toolDAO.getToolByID(activity .getToolID())); log.debug("Tool export content : " + activity.getActivityTitle() + " by contentID :" @@ -520,7 +615,8 @@ } catch (Exception e) { String msg = activity.getToolDisplayName() + " export tool content failed:" + e.toString(); log.error(msg, e); - // Try to delete tool.xml. This makes export_failed and tool.xml does not exist simultaneously. + // Try to delete tool.xml. This makes export_failed and + // tool.xml does not exist simultaneously. String toolPath = FileUtil.getFullPath(contentDir, activity.getToolContentID().toString()); String toolFileName = FileUtil.getFullPath(toolPath, ExportToolContentService.TOOL_FILE_NAME); File toolFile = new File(toolFileName); @@ -537,7 +633,8 @@ } } // end all activities export - // skipping unwanted elements; learning design DTO is altered but not persisted; + // skipping unwanted elements; learning design DTO is altered + // but not persisted; Iterator groupingIter = ldDto.getGroupings().iterator(); while (groupingIter.hasNext()) { if (groupingsToSkip.contains(groupingIter.next().getGroupingID())) { @@ -605,8 +702,8 @@ /** * Generate temporary files: resources.xml and transitions.xml.
- * Transform LAMS format learning_design.xml with resources.xml and transitions.xml into ims_learning_design.xml - * file. + * Transform LAMS format learning_design.xml with resources.xml and + * transitions.xml into ims_learning_design.xml file. * * @param resChildren * @param rootDir @@ -619,7 +716,8 @@ String xsltDir = FileUtil.getFullPath(rootDir, ExportToolContentService.DIR_XSLT_TEMP); String ldFileName = FileUtil.getFullPath(xsltDir, ExportToolContentService.LEARNING_DESIGN_FILE_NAME); - // copy XSLT file to contentDir, so that the XSLT document() function does not need absolute path file. + // copy XSLT file to contentDir, so that the XSLT document() function + // does not need absolute path file. File xslt = new File(FileUtil.getFullPath(xsltDir, "ims.xslt")); FileUtil.copyFile(xsltIn, xslt); @@ -656,8 +754,10 @@ // create transitions DOM file List sortedActList = getSortedActivities(ldDto); - // Need to know what activities are branching activities, so we can set up conditions for their child sequences - // Can't just do it for all sequences as the sequence could be in an optional activity + // Need to know what activities are branching activities, so we can set + // up conditions for their child sequences + // Can't just do it for all sequences as the sequence could be in an + // optional activity Set branchingActivityIds = new HashSet(); for (AuthoringActivityDTO actDto : sortedActList) { if (actDto.getActivityTypeID().equals(Activity.CHOSEN_BRANCHING_ACTIVITY_TYPE) @@ -679,7 +779,8 @@ log.debug("Export IMS: Put actitivies " + actDto.getActivityTitle() + "[" + actDto.getToolContentID() + "] into Transition tag."); - // All sequence activities are within braching or an optional sequence, so they don't go into the transition + // All sequence activities are within braching or an optional + // sequence, so they don't go into the transition // list. if (actDto.getActivityTypeID().equals(Activity.SEQUENCE_ACTIVITY_TYPE)) { String attributeValue = ExportToolContentService.IMS_PREFIX_COMPLEX_REF @@ -693,7 +794,8 @@ } } else if (actDto.getParentActivityID() == null) { - // Only want to add it to the list of transition activities if it is the top level, as this generates + // Only want to add it to the list of transition activities if + // it is the top level, as this generates // the initial sequence. Attribute att = null; @@ -744,7 +846,8 @@ log.debug("Export IMS: Transtion() file generated sucess: " + transFile.getAbsolutePath()); - // create the properties file and conditions file - needed for gate showing gates when open and branches when + // create the properties file and conditions file - needed for gate + // showing gates when open and branches when // determined propertiesRoot.setChildren(propertiesChildren); propertiesDom.setRootElement(propertiesRoot); @@ -786,9 +889,10 @@ } /** - * Generate the nodes for a property and the related conditions. The first element is the property, which goes in - * the tag, the second through fourth elements are the if-then-else that makes up the condition and - * goes in the tag. + * Generate the nodes for a property and the related conditions. The + * first element is the property, which goes in the tag, + * the second through fourth elements are the if-then-else that makes up + * the condition and goes in the tag. * * @param activityId * @return @@ -844,11 +948,15 @@ } /** - * This quite complex method will return a sorted acitivityDTO list according to current LD DTO.
- * It considers the broken LD situation. A first activity will always be first one, but others in the broken - * sequence in this LD sorted by randomly. In one broken sequence, all activities will sorted by transition.
- * The reason to use lots "for" is Activity DTO does not contain next transition information. It has to be iterator - * all transitions or activities. + * This quite complex method will return a sorted acitivityDTO list + * according to current LD DTO.
+ * It considers the broken LD situation. A first activity will always be + * first one, but others in the broken sequence in this LD sorted by + * randomly. In one broken sequence, all activities will sorted by + * transition.
+ * The reason to use lots "for" is Activity DTO does not contain next + * transition information. It has to be iterator all transitions or + * activities. * * @param ldDto * @return @@ -861,7 +969,8 @@ Long firstActId = ldDto.getFirstActivityID(); HashMap activities = new HashMap(); - // Put first activity into sorted list and copy the rest of the activities into a working map so we can find + // Put first activity into sorted list and copy the rest of the + // activities into a working map so we can find // them easily. // They can be removed from the map as we go so we don't reprocess them. Iterator iter = ldDto.getActivities().iterator(); @@ -905,13 +1014,16 @@ break; } - // already achieve one sequence end, but it still exist unsorted transition, it means - // this ld is broken one, there are at least two "first act" (there is no "transition to") + // already achieve one sequence end, but it still exist unsorted + // transition, it means + // this ld is broken one, there are at least two "first act" + // (there is no "transition to") if (!find) { for (AuthoringActivityDTO act : activities.values()) { boolean isFirst = true; for (TransitionDTO tranDto : transList) { - // there is some transition to this act, it is not "head activity" then skip this act. + // there is some transition to this act, it is + // not "head activity" then skip this act. if (tranDto.getToActivityID().equals(act.getActivityID())) { isFirst = false; break; @@ -934,17 +1046,19 @@ } } - // there are some sole activities exist in this LD,append them into sorted list end. + // there are some sole activities exist in this LD,append them into + // sorted list end. if (activities.size() > 0) { sortedActList.addAll(activities.values()); } return sortedActList; } /** - * Move LAMS tool.xml from tool folder to export content root folder and modify it to {toolContentID}.xml file. - * Cache all attachement files from this tool into ArrayList, which will be save into a temporary file - * (resources.xml) and used by XSLT. + * Move LAMS tool.xml from tool folder to export content root folder and + * modify it to {toolContentID}.xml file. Cache all attachement files + * from this tool into ArrayList, which will be save into a temporary + * file (resources.xml) and used by XSLT. * * @param rootDir * @param activity @@ -973,22 +1087,25 @@ Document doc = sax.build(new FileInputStream(toolFile)); Element root = doc.getRootElement(); - // cache DTO object class and transform it into a tag : for later import use by XStream. + // cache DTO object class and transform it into a tag : + // for later import use by XStream. String mainObject = root.getName(); root.setName(activity.getToolSignature()); Namespace ns = Namespace.getNamespace(ExportToolContentService.IMS_TOOL_NS_PREFIX + activity.getToolSignature() + "_ims.xsd"); root.setNamespace(ns); - // add mainObject tag: it save the Tool DTO class name. It is useful when importing by XStream + // add mainObject tag: it save the Tool DTO class name. + // It is useful when importing by XStream // (perhaps a future function) Element mainObjectEle = new Element(ExportToolContentService.IMS_TOOL_MAIN_OBJECT); mainObjectEle.setText(mainObject); root.addContent(mainObjectEle); updateNamespaceForChildren(root, ns); - // create a new tools.xml file with toolContentID.xml as name. + // create a new tools.xml file with toolContentID.xml as + // name. File imsToolFile = new File(FileUtil.getFullPath(xsltDir, activity.getToolContentID() .toString() + ".xml")); @@ -1000,17 +1117,20 @@ } catch (JDOMException e) { log.error("IMS export occurs error when reading tool xml for " + toolFileName + "."); } - // tool node already gather into LD root folder imstools.xml file, delete old tool.xml from tool + // tool node already gather into LD root folder + // imstools.xml file, delete old tool.xml from tool // folder toolFile.delete(); continue; } - // handle other attachment files from tools, treat them as resource of IMS package + // handle other attachment files from tools, treat them as + // resource of IMS package List fileChildren = new ArrayList(); // resource TAG Element resEle = new Element(ExportToolContentService.IMS_TAG_RESOURCE); - // the resource identifier should be "R_toolSignature_toolContentId" + // the resource identifier should be + // "R_toolSignature_toolContentId" Attribute resAtt = new Attribute(ExportToolContentService.IMS_ATTR_IDENTIFIER, ExportToolContentService.IMS_PREFIX_RESOURCE_IDENTIFIER + activity.getToolSignature() + "-" + activity.getToolContentID().toString()); @@ -1062,7 +1182,8 @@ // serialize tool xml into local file. XStream toolXml = new XStream(); - // get back Xstream default convert, create proxy then register it to XStream parser. + // get back Xstream default convert, create proxy then register + // it to XStream parser. Converter c = toolXml.getConverterLookup().defaultConverter(); FileInvocationHandler handler = null; if (!fileHandleClassList.isEmpty()) { @@ -1123,8 +1244,9 @@ } /** - * Import the learning design from the given path. Set the importer as the creator. If the workspaceFolderUid is - * null then saves the design in the user's own workspace folder. + * Import the learning design from the given path. Set the importer as + * the creator. If the workspaceFolderUid is null then saves the design + * in the user's own workspace folder. * * @param designFile * @param importer @@ -1155,12 +1277,14 @@ if (wddxPacket == null || !(wddxPacket.startsWith(" toolsErrorMsgs) throws ImportToolContentException { @@ -1241,7 +1365,8 @@ String toolPath = FileUtil.getFullPath(learningDesignPath, activity.getToolContentID().toString()); - // To create a new toolContent according to imported tool signature name. + // To create a new toolContent according to imported tool + // signature name. // get tool by signature Tool newTool = new ToolCompatibleStrategy().getTool(activity.getToolSignature()); @@ -1275,8 +1400,10 @@ ToolContentManager contentManager = (ToolContentManager) findToolService(newTool); - // If this is a tool adapter tool, pass the customCSV to the special importToolContent method - // Otherwise invoke the normal tool importToolContentMethod + // If this is a tool adapter tool, pass the customCSV to + // the special importToolContent method + // Otherwise invoke the normal tool + // importToolContentMethod if (contentManager instanceof ToolAdapterContentManager) { ToolAdapterContentManager toolAdapterContentManager = (ToolAdapterContentManager) contentManager; toolAdapterContentManager.importToolContent(newContent.getToolContentId(), @@ -1291,7 +1418,8 @@ new Object[] { newTool.getToolDisplayName(), e.toString() }); log.error(error, e); toolsErrorMsgs.add(error); - // remove any unsucessed activities from new Learning design. + // remove any unsucessed activities from new Learning + // design. removedActMap.put(activity.getActivityID(), activity); } } // end all activities import @@ -1321,7 +1449,8 @@ throw new ImportToolContentException(e); } - // if the design was read only (e.g. exported a runtime sequence), clear the read only flag + // if the design was read only (e.g. exported a runtime + // sequence), clear the read only flag ldDto.setDateReadOnly(null); ldDto.setReadOnly(false); @@ -1337,13 +1466,15 @@ } /** - * Call xstream to get the POJOs from the XML file. To make it backwardly compatible we catch any exceptions due to - * added fields, remove the field using the ToolContentVersionFilter functionality and try to reparse. We can't - * nominate the problem fields in advance as we are making XML created by newer versions of LAMS compatible with an + * Call xstream to get the POJOs from the XML file. To make it + * backwardly compatible we catch any exceptions due to added fields, + * remove the field using the ToolContentVersionFilter functionality and + * try to reparse. We can't nominate the problem fields in advance as we + * are making XML created by newer versions of LAMS compatible with an * older version. * - * This logic depends on the exception message containing the text. When we upgrade xstream, we must check that this - * message doesn't change. + * This logic depends on the exception message containing the text. When + * we upgrade xstream, we must check that this message doesn't change. * *
      * 	com.thoughtworks.xstream.converters.ConversionException: unknownField : unknownField
@@ -1365,7 +1496,8 @@
 	ConversionException finalException = null;
 	String lastFieldRemoved = "";
 	ToolContentVersionFilter contentFilter = null;
-	// cap the maximum number of retries to 30 - if we add more than 30 new fields then we need to rethink our
+	// cap the maximum number of retries to 30 - if we add more than 30 new
+        // fields then we need to rethink our
 	// strategy
 	int maxRetries = 30;
 	int numTries = 0;
@@ -1464,7 +1596,8 @@
     }
 
     /**
-     * Extract the class name or field name from a ConversionException message
+     * Extract the class name or field name from a ConversionException
+     * message
      */
     private String extractValue(String message, String fieldToLookFor) {
 	try {
@@ -1538,7 +1671,8 @@
 	    if (filterClass != null && !StringUtils.equals(fromVersion, toVersion)) {
 		filterVersion(toolFilePath, fromVersion, toVersion);
 	    }
-	    // clear and ensure next activity can get correct filter thru registerImportVersionFilterClass().
+	    // clear and ensure next activity can get correct filter thru
+                // registerImportVersionFilterClass().
 	    filterClass = null;
 
 	    // read tool file after transform.
@@ -1551,7 +1685,8 @@
 
 		    Long uuid = NumberUtils.createLong(BeanUtils.getProperty(fileNode.instance,
 			    fileNode.name.uuidFieldName));
-		    // For instance, item class in share resource tool may be url or single file. If it is URL, then the
+		    // For instance, item class in share resource tool may
+                        // be url or single file. If it is URL, then the
 		    // file uuid will be null. Ignore it!
 		    if (uuid == null) {
 			continue;
@@ -1571,14 +1706,16 @@
 		    String fullFileName = FileUtil.getFullPath(toolContentPath, realFileName);
 		    log.debug("Tool attachement files/packages are going to upload to repository " + fullFileName);
 
-		    // to check if the file is package (with extension name ".zip") or single file (no extension name).
+		    // to check if the file is package (with extension name
+                        // ".zip") or single file (no extension name).
 		    File file = new File(fullFileName);
 		    boolean isPackage = false;
 		    if (!file.exists()) {
 			file = new File(fullFileName + ExportToolContentService.EXPORT_TOOLCONTNET_ZIP_SUFFIX);
 			realFileName = realFileName + ExportToolContentService.EXPORT_TOOLCONTNET_ZIP_SUFFIX;
 			isPackage = true;
-			// if this file is norpackage neither single file, throw exception.
+			// if this file is norpackage neither single file, throw
+                        // exception.
 			if (!file.exists()) {
 			    throw new ImportToolContentException("Content attached file/package can not be found: "
 				    + fullFileName + "(.zip)");
@@ -1742,7 +1879,8 @@
     }
 
     /**
-     * If there are any errors happen during tool exporting content. Writing failed message to file.
+     * If there are any errors happen during tool exporting content. Writing
+     * failed message to file.
      */
     private void writeErrorToToolFile(String rootPath, Long toolContentId, String msg) {
 	// create tool's save path
@@ -1819,23 +1957,28 @@
 	Map activityMapper = new HashMap();
 	Map activityByUIIDMapper = new HashMap();
 
-	// as we create the activities, we need to record any "default activities" for the sequence activity
-	// and branching activities to process later - we can't process them now as the children won't have
-	// been created yet and if we leave it till later and then find all the activities we are
+	// as we create the activities, we need to record any "default
+        // activities" for the sequence activity
+	// and branching activities to process later - we can't process them now
+        // as the children won't have
+	// been created yet and if we leave it till later and then find all the
+        // activities we are
 	// going through the activity set over and over again for no reason.
 	Map defaultActivityToParentActivityMapping = new HashMap();
 
 	for (AuthoringActivityDTO actDto : actDtoList) {
 	    Activity act = getActivity(actDto, groupingMapper, toolMapper, defaultActivityToParentActivityMapping);
-	    // so far, the activitiy ID is still old one, so setup the mapping relation between old ID and new activity.
+	    // so far, the activitiy ID is still old one, so setup the
+                // mapping relation between old ID and new activity.
 	    activityMapper.put(act.getActivityId(), act);
 	    activityByUIIDMapper.put(act.getActivityUIID(), act);
 	    // if this act is removed, then does not save it into LD
 	    if (!removedActMap.containsKey(actDto.getActivityID())) {
 		actList.add(act);
 	    }
 	}
-	// rescan the activity list and refresh their parent activity and input activities
+	// rescan the activity list and refresh their parent activity and input
+        // activities
 	for (AuthoringActivityDTO actDto : actDtoList) {
 	    Activity act = activityMapper.get(actDto.getActivityID());
 	    if (removedActMap.containsKey(actDto.getActivityID())) {
@@ -1850,7 +1993,8 @@
 		    act.setParentUIID(null);
 		} else {
 		    act.setParentActivity(parent);
-		    // also add child as Complex activity: It is useless for persist data, but helpful for validate in
+		    // also add child as Complex activity: It is useless for
+                        // persist data, but helpful for validate in
 		    // learning design!
 		    if (parent.isComplexActivity()) {
 			Set set = ((ComplexActivity) parent).getActivities();
@@ -1883,12 +2027,17 @@
 	    activityDAO.insert(act);
 	}
 
-	// Process the "first child" for any sequence activities and the "default branch" for branching activities.
-	// If the child has been removed then leave it as null as the progress engine will cope (it will pick a
-	// new one based on the lack of an input transition) and in authoring the author will just have to set
-	// up a new first activity. If the default branch is missing and other details are missing (e.g. missing
+	// Process the "first child" for any sequence activities and the
+        // "default branch" for branching activities.
+	// If the child has been removed then leave it as null as the progress
+        // engine will cope (it will pick a
+	// new one based on the lack of an input transition) and in authoring
+        // the author will just have to set
+	// up a new first activity. If the default branch is missing and other
+        // details are missing (e.g. missing
 	// conditions)
-	// from the design then it may have to be fixed in authoring before it will run, so the default branch missing
+	// from the design then it may have to be fixed in authoring before it
+        // will run, so the default branch missing
 	// case needs to be picked up by the validation (done later).
 	if (defaultActivityToParentActivityMapping.size() > 0) {
 	    for (Integer childUIID : defaultActivityToParentActivityMapping.keySet()) {
@@ -1925,7 +2074,8 @@
 			    }
 			    boolean transitionBreak = true;
 			    for (TransitionDTO transDto : transDtoList) {
-				// find out the transition of current first activity
+				// find out the transition of current first
+                                // activity
 				if (nextActId.equals(transDto.getFromActivityID())) {
 				    transitionBreak = false;
 				    nextActId = transDto.getToActivityID();
@@ -1940,13 +2090,17 @@
 				    }
 				    // already found the desire transition
 				    break;
-				    // if found flag is false yet, then it means the 2nd node remove as well,
+				    // if found flag is false yet, then it
+                                        // means the 2nd node remove as well,
 				    // continue try 3rd...
 				}
 			    }
-			    // This activity also removed!!! then retrieve again
-			    // If found is false, then the nextAct is still not available, then continue find.
-			    // tranisitionBreak mean the activity is removed but it can not find its transition to
+			    // This activity also removed!!! then retrieve
+                                // again
+			    // If found is false, then the nextAct is still
+                                // not available, then continue find.
+			    // tranisitionBreak mean the activity is removed
+                                // but it can not find its transition to
 			    // decide next available activity.
 			    if (found || transitionBreak) {
 				break;
@@ -2001,7 +2155,8 @@
 	if (listOfValidationErrorDTOs.size() > 0) {
 	    ld.setValidDesign(false);
 	    log.error(listOfValidationErrorDTOs);
-	    // throw new ImportToolContentException("Learning design validate error.");
+	    // throw new ImportToolContentException("Learning design
+                // validate error.");
 	} else {
 	    ld.setValidDesign(true);
 	}
@@ -2015,7 +2170,8 @@
     }
 
     /**
-     * Method to sort activity DTO according to the rule: Paretns is before their children.
+     * Method to sort activity DTO according to the rule: Paretns is before
+     * their children.
      * 
      * @param activities
      * @return
@@ -2024,7 +2180,8 @@
 	List result = new ArrayList();
 	List actIdList = new ArrayList();
 
-	// NOTICE: this code can not handle all nodes have their parents, ie, there is at least one node parent is
+	// NOTICE: this code can not handle all nodes have their parents, ie,
+        // there is at least one node parent is
 	// null(root).
 	int failureToleranceCount = 5000;
 	while (!activities.isEmpty() && failureToleranceCount > 0) {
@@ -2056,10 +2213,12 @@
     }
 
     /**
-     * Get learning design object from this Learning design DTO object. It also following our import rules:
+     * Get learning design object from this Learning design DTO object. It
+     * also following our import rules:
      * 
  • lams_license - Assume same in all lams system. Import same ID
  • *
  • lams_copy_type - Set to 1.This indicates it is "normal" design.
  • - *
  • lams_workspace_folder - An input parameters to let user choose import workspace
  • + *
  • lams_workspace_folder - An input parameters to let user choose + * import workspace
  • *
  • User - The person who execute import action
  • *
  • OriginalLearningDesign - set to null
  • * @@ -2206,12 +2365,15 @@ } /** - * Creates the map entry between a branch sequence activity and a group. We need the group maps and the activity - * maps so that we can update the ids to the groups and the activities. Therefore this method must be done after all - * the groups are imported and the activities are imported. + * Creates the map entry between a branch sequence activity and a group. + * We need the group maps and the activity maps so that we can update + * the ids to the groups and the activities. Therefore this method must + * be done after all the groups are imported and the activities are + * imported. * - * Note: there isn't an set in the learning design for the branch mappings. The group objects actually contain the - * link to the mappings, so this method updates the group objects. + * Note: there isn't an set in the learning design for the branch + * mappings. The group objects actually contain the link to the + * mappings, so this method updates the group objects. */ private BranchActivityEntry getBranchActivityEntry(BranchActivityEntryDTO entryDto, Map groupByUIIDMapper, Map activityByUIIDMapper) { @@ -2278,7 +2440,8 @@ Activity fromAct = activityMapper.get(transDto.getFromActivityID()); trans.setFromActivity(fromAct); trans.setFromUIID(fromAct.getActivityUIID()); - // also set transition to activity: It is nonsense for persisit data, but it is help this learning design + // also set transition to activity: It is nonsense for persisit data, + // but it is help this learning design // validated fromAct.setTransitionTo(trans); // set to null @@ -2288,7 +2451,8 @@ Activity toAct = activityMapper.get(transDto.getToActivityID()); trans.setToActivity(toAct); trans.setToUIID(toAct.getActivityUIID()); - // also set transition to activity: It is nonsense for persisit data, but it is help this learning design + // also set transition to activity: It is nonsense for persisit data, + // but it is help this learning design // validated toAct.setTransitionFrom(trans); @@ -2320,9 +2484,11 @@ Activity act = Activity.getActivityInstance(type); switch (act.getActivityTypeId()) { case Activity.TOOL_ACTIVITY_TYPE: - // get back the toolContent in new system by toolContentID in old system. + // get back the toolContent in new system by toolContentID in + // old system. ToolContent content = toolMapper.get(actDto.getActivityID()); - // if activity can not find matching tool, the content should be null. + // if activity can not find matching tool, the content should be + // null. if (content != null) { ((ToolActivity) act).setTool(content.getTool()); ((ToolActivity) act).setToolContentId(content.getToolContentId()); @@ -2425,7 +2591,8 @@ act.setLibraryActivityUiImage(actDto.getLibraryActivityUIImage()); act.setOrderId(actDto.getOrderID()); - // temporarily set as to null, after scan all activities, then set it to valid value. + // temporarily set as to null, after scan all activities, then set it to + // valid value. act.setParentActivity(null); act.setParentUIID(actDto.getParentUIID());