You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2013/01/26 20:24:12 UTC
svn commit: r1438950 -
/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
Author: gawor
Date: Sat Jan 26 19:24:12 2013
New Revision: 1438950
URL: http://svn.apache.org/viewvc?rev=1438950&view=rev
Log:
improve cross space via id lookup
Modified:
geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java?rev=1438950&r1=1438949&r2=1438950&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/ConfluenceCleanupWriter.java Sat Jan 26 19:24:12 2013
@@ -103,6 +103,35 @@ public class ConfluenceCleanupWriter ext
return null;
}
+ private String findPageByID(String id) throws Exception {
+ String location = findPageByID(exporter, id);
+ if (location == null) {
+ for (SiteExporter siteExporter : SiteExporter.siteExporters) {
+ if (exporter == siteExporter) {
+ continue;
+ }
+ location = findPageByID(siteExporter, id);
+ if (location != null) {
+ break;
+ }
+ }
+ }
+ return location;
+ }
+
+ private String findPageByID(SiteExporter siteExporter, String url) throws Exception {
+ AbstractPage p = siteExporter.findPageByID(url);
+ if (p != null) {
+ String prefix = getRelativePath(SiteExporter.rootOutputDir, getPageDirectory(), siteExporter.outputDir);
+ String location = prefix + p.getPath();
+ if (exporter != siteExporter) {
+ System.out.println("Cross space link (via id) to " + location);
+ }
+ return location;
+ }
+ return null;
+ }
+
//CHECKSTYLE:OFF
public void startElement(String uri, String localName, String qName, final Attributes atts)
throws SAXException {
@@ -144,14 +173,23 @@ public class ConfluenceCleanupWriter ext
} else if (href != null && href.startsWith("/confluence/plugins/")) {
newAtts.addMapping("href", SiteExporter.ROOT + href.substring(11));
} else if (href != null && href.contains("/confluence/pages/viewpage.action")) {
+ String params = "";
+ if (href.indexOf('#') != -1) {
+ params = href.substring(href.indexOf('#'));
+ href = href.substring(0, href.indexOf('#'));
+ }
int idx = href.indexOf("pageId=");
String id = href.substring(idx + 7);
- Page p = exporter.findPageByID(id);
- if (p != null) {
- newAtts.addMapping("href", p.createFileName());
- } else {
- System.out.println("Could not find page for id: " + id
- + " linked from " + page.getTitle());
+ try {
+ String location = findPageByID(id);
+ if (location != null) {
+ newAtts.addMapping("href", location + params);
+ } else {
+ System.out.println("Could not find page for id: " + id
+ + " linked from " + page.getTitle());
+ }
+ } catch (Exception e) {
+ throw new SAXException(e);
}
} else if (href != null && href.contains("/confluence/download/attachments")) {
href = href.substring(href.lastIndexOf("/"));