Dokuwiki, improved tagconverter and hierarchy
diff --git a/src/com/atlassian/uwc/converters/dokuwiki/TagConverter.java b/src/com/atlassian/uwc/converters/dokuwiki/TagConverter.java
index 5db628d..fe37738 100644
--- a/src/com/atlassian/uwc/converters/dokuwiki/TagConverter.java
+++ b/src/com/atlassian/uwc/converters/dokuwiki/TagConverter.java
@@ -36,6 +36,7 @@
 			}
 			String[] tagarray = all.split(" ");
 			for (String tag : tagarray) {
+				if ("".equals(tag.trim())) continue;
 				log.debug("adding label: " + tag);
 				page.addLabel(tag);
 			}
diff --git a/src/com/atlassian/uwc/converters/dokuwiki/TagConverterTest.java b/src/com/atlassian/uwc/converters/dokuwiki/TagConverterTest.java
index 61c231a..2b6a8b6 100644
--- a/src/com/atlassian/uwc/converters/dokuwiki/TagConverterTest.java
+++ b/src/com/atlassian/uwc/converters/dokuwiki/TagConverterTest.java
@@ -49,5 +49,18 @@
 		assertNotNull(actual);
 		assertEquals(expected, actual);
 	}
+	
+	public void testConvertTags_none() {
+		Page page = new Page(null);
+		String input, expected, actual;
+		input = "{{tag>}}\n" + 
+				"";
+		page.setOriginalText(input);
+		tester.convert(page);
+		assertNotNull(page.getLabels());
+		assertEquals(0, page.getLabels().size());
+		actual = page.getLabelsAsString();
+		assertNull(actual);
+	}
 
 }
diff --git a/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchy.java b/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchy.java
index e0b37da..a8ed1c5 100644
--- a/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchy.java
+++ b/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchy.java
@@ -161,8 +161,8 @@
 			for (String name : collisions) {
 				String eqname = equalize(name);
 				String childname = equalize(child.getName());
+				log.debug("Examining collisions candidate: '" + eqname + "' for this child: '" + childname + "'");
 				if (childname.equals(eqname)) {
-					log.debug("Fixing collisions? " + eqname + " vs. " + childname);
 					String parent = child.getParent().getName();
 					log.debug("parent = " + parent);
 					if (parent == null) continue;
@@ -178,8 +178,6 @@
 	}
 
 	public Vector<String> getCollisionsForThisNode(HierarchyNode node) {
-		log.debug("node.getPage: " + node.getPage());
-		if (node.getPage() != null) log.debug("node.getPage.getSpacekey: " + node.getPage().getSpacekey());
 		String spacekey = (node.getPage() != null && node.getPage().getSpacekey() != null)?
 				node.getPage().getSpacekey() :
 				getProperties().getProperty("spacekey", "");
@@ -315,10 +313,7 @@
 		currentpage = page;
 		combineHomepageNodes = false;
 		currentParent = null;
-		//DELETE
-		if (page.getFile().getPath().endsWith("forumdescription.txt")) {
-			int food = 0;
-		}
+
 		super.buildRelationships(page, root);
 		if (combineHomepageNodes) {
 			combineHomepages(page);
@@ -345,6 +340,7 @@
 	
 	private void combineHomepages(HierarchyNode nullPageNode, HierarchyNode noChildrenNode,
 			Page page) {
+		if (noChildrenNode.getPage() == null) return;//indicates this isn't the right scenario to combine
 		//this one represents the one with all the hierarchy data
 		nullPageNode.setPage(page); 
 		//this one represents the one that (used) to have page data. We don't need it anymore
diff --git a/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchyTest.java b/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchyTest.java
index 89565ba..6951fd5 100644
--- a/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchyTest.java
+++ b/src/com/atlassian/uwc/hierarchies/DokuwikiHierarchyTest.java
@@ -581,6 +581,82 @@
 		testNodeResults(pienodes3, expfruit);
 	}
 	
+	public void testAncestorSameName() {
+		
+		Properties props = tester.getProperties();
+		props.setProperty("collision-titles-food", "Fruit");
+		props.put("filepath-hierarchy-ext", "");
+		String samplepath = "sampleData/hierarchy/dokuwiki-samename"; 
+		props.put("filepath-hierarchy-ignorable-ancestors", samplepath);
+		//set a property to identify the position of the homepage file
+		props.put("hierarchy-homepage-position", "sibling"); //default is child
+		//set a property to identify the homepage file 
+		props.put("hierarchy-homepage-dokuwiki-filename", ""); //default is empty. means the nodename
+		tester.setProperties(props);
+		
+		File sampledir = new File(samplepath);
+		Collection<Page> pages = new Vector<Page>();
+		assertTrue(sampledir.exists());
+		File[] files = sampledir.listFiles(new NoSvnFilter());
+		pages = createPages(pages, files);
+		
+		HierarchyNode actual = tester.buildHierarchy(pages);
+		assertNotNull(actual);
+		String title = "Apple Fruit";
+		assertTrue(foundNode(actual, title));
+		assertEquals(1, howManyNodesWithThisTitle(actual, title));
+	}
+	
+	private int howManyNodesWithThisTitle(HierarchyNode node, String title) {
+		if (node.getChildren().size() > 0) {
+			int count = 0;
+			for (Iterator<HierarchyNode> iter = node.getChildIterator(); iter.hasNext();) {
+				HierarchyNode child = iter.next();
+				count += howManyNodesWithThisTitle(child, title);
+			}
+			return count;
+		}
+		else {
+			if (title.equals(node.getPage().getName())) {
+				return 1;
+			}
+			return 0;
+		}
+	}
+
+	private static Logger slog = Logger.getLogger(DokuwikiHierarchyTest.class);
+	public static boolean foundNode(HierarchyNode node, String title) {
+		if (node.getChildren().size() > 0) {
+			for (Iterator<HierarchyNode> iter = node.getChildIterator(); iter.hasNext();) {
+				HierarchyNode child = iter.next();
+				if (foundNode(child, title)) {
+					slog.debug(child.getName());
+					return true;
+				}
+			}
+			return false;
+		}
+		else {
+			if (title.equals(node.getPage().getName())) {
+				return true;
+			}
+			return false;
+		}
+	}
+
+	private void lastNodeShouldHaveTitle(HierarchyNode node, String title) {
+		if (node.getChildren().size() > 0) {
+			for (Iterator<HierarchyNode> iter = node.getChildIterator(); iter.hasNext();) {
+				HierarchyNode child = iter.next();
+				lastNodeShouldHaveTitle(child, title);
+			}
+		}
+		else {
+			assertEquals(title, node.getName());
+		}
+		
+	}
+
 	private Collection<Page> createPages(Collection<Page> pages, File[] files) {
 		for (File file : files) {
 			if (file.getName().endsWith(".swp")) continue;
diff --git a/src/com/atlassian/uwc/ui/ConverterEngine.java b/src/com/atlassian/uwc/ui/ConverterEngine.java
index 72da41a..7b81947 100644
--- a/src/com/atlassian/uwc/ui/ConverterEngine.java
+++ b/src/com/atlassian/uwc/ui/ConverterEngine.java
@@ -52,6 +52,7 @@
 import com.atlassian.uwc.converters.xml.DefaultXmlEvents;

 import com.atlassian.uwc.converters.xml.XmlEvents;

 import com.atlassian.uwc.filters.FilterChain;

+import com.atlassian.uwc.hierarchies.DokuwikiHierarchyTest;

 import com.atlassian.uwc.hierarchies.HierarchyBuilder;

 import com.atlassian.uwc.hierarchies.HierarchyNode;

 import com.atlassian.uwc.splitters.PageSplitter;

@@ -1515,7 +1516,6 @@
     		this.feedback = Feedback.CANCELLED;

     		return progress;

     	}

-        

     	// First upload the page contained in this node

         Page page = node.getPage();

         // create missing nodes - like a directory that didn't have a corresponding page

diff --git a/src/com/atlassian/uwc/ui/ConverterEngineTest.java b/src/com/atlassian/uwc/ui/ConverterEngineTest.java
index 55784af..566ea2d 100644
--- a/src/com/atlassian/uwc/ui/ConverterEngineTest.java
+++ b/src/com/atlassian/uwc/ui/ConverterEngineTest.java
@@ -3613,6 +3613,7 @@
 		}
 		
 	}
+	
 
 	private void deleteSpace(String space, ConfluenceServerSettings confSettings) throws XmlRpcException, IOException {
 		confSettings.url = confSettings.url.replaceFirst("https?://", "");