public void convert()

in src/main/java/com/atlassian/uwc/ui/ConverterEngine.java [356:448]


	public void convert(List<File> pages, List<String> converterStrings, boolean sendToConfluence, String filterPattern) {
		log.info("Starting conversion.");

		initConversion();

		//create converters
		ArrayList<Converter> converters = createConverters(converterStrings);

		//create page objects - Recurse through directories, adding all files
		FileFilter filter = createFilter(filterPattern);
		List<Page> allPages = createPages(filter, pages);

		//fix progressbar max, which is dependent on the previous two lists
		int steps = getNumberOfSteps(pages.size(), allPages.size(), converterStrings.size(), converters.size(), sendToConfluence);
		this.state.updateMax(steps);


		//convert the files
		if (convertPages(allPages, converters)) {
			//in case converting the pages disqualified some pages, we need to break if there are no pages left
			if (allPages.size() < 1) {
				String message = "All pages submitted were disqualified for various reasons. Could not complete conversion.";
				log.warn(message);
				this.errors.addError(Feedback.CONVERTER_ERROR, message, true);
				this.state.updateMax(this.state.getStep()); //complete progress bar, prematurely
				return;
			}
			//in case converting the pages disqualified some pages, we need to recompute progressbarmax
			steps = getNumberOfSteps(pages.size(), allPages.size(), converterStrings.size(), converters.size(), sendToConfluence);
			if (steps != this.state.getMax()) this.state.updateMax(steps);

			// do final required conversions. This step is seperate, due to state saving issues
			convertWithRequiredConverters(allPages);

			//save pages if engine-saves-to-disk property is true. Useful for debugging.
			//We are making this opt-in because users that don't need it will get a speed boost with fewer disk calls
			if (Boolean.parseBoolean(this.miscProperties.getProperty(PROPKEY_ENGINE_SAVES_TO_DISK, "false")))
				savePages(allPages, filterPattern);
			else log.debug("Engine Saves To Disk setting turned off.");

			//handling page histories and not sorting on create
			if (isHandlingPageHistories() && 
					!(isPageHistorySortOnCreate())) {
				allPages = sortByHistory(allPages);
			}

			if (hierarchyHandler == HierarchyHandler.HIERARCHY_BUILDER && hierarchyBuilder != null) {
				//tell the hierarchy builder about the page histories framework
				//do this here so that we're sure the page histories properties are set
				if (hierarchyBuilder.getProperties() != null) { 
					hierarchyBuilder.getProperties().setProperty("switch."+NONCONVERTERTYPE_PAGEHISTORYPRESERVATION, isHandlingPageHistories()+"");
					if (getPageHistorySuffix() != null)	
						hierarchyBuilder.getProperties().setProperty("suffix."+NONCONVERTERTYPE_PAGEHISTORYPRESERVATION, getPageHistorySuffix());
				}
				//tell the hierarchy some other information
				if (hierarchyBuilder.getProperties() != null) {
					hierarchyBuilder.getProperties().setProperty("spacekey", settings.getSpace());
				}
				//build the hierarchy
				HierarchyNode root = hierarchyBuilder.buildHierarchy(allPages);
				int currenttotal = root.countDescendants()-1; //-1 for the null root;
				log.debug("number of nodes in the hierarchy = " + root.countDescendants());
				//upload pages, if the user approves
				if (sendToConfluence && this.running) { //check here so that hierarchy can impact collisions without upload
					if (Boolean.parseBoolean(this.miscProperties.getProperty("onlyorphans", "false"))) {
						log.debug("Orphan attachments only.");
						noteAttachments(root);
					} 
					else {
						writeHierarchy(root, currenttotal, settings.getSpace());
					}
					handleOrphanAttachments();
				}
				else if (!sendToConfluence){
					log.debug("Send To Confluence setting turned off. --> Not uploading pages.");
				}
			} else { //no hierarchy
				if (sendToConfluence && this.running) {//check here so that hierarchy can impact collisions without upload
					writePages(allPages, settings.getSpace());
					handleOrphanAttachments();
				}
				else if (!sendToConfluence){
					log.debug("Send To Confluence setting turned off. --> Not uploading pages.");
				}
			}

			//check for namespace collisions and emit errors if found
			//(after hierarchy has had a chance to make changes)
			listCollisions(allPages);
			clearAttachedFileList();
		}	
		log.info("Conversion Complete");
	}