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 2012/12/22 22:25:57 UTC
svn commit: r1425347 - in
/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki:
BlogEntrySummary.java SiteExporter.java
Author: gawor
Date: Sat Dec 22 21:25:57 2012
New Revision: 1425347
URL: http://svn.apache.org/viewvc?rev=1425347&view=rev
Log:
deal with blogs a bit better
Modified:
geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/BlogEntrySummary.java
geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/BlogEntrySummary.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/BlogEntrySummary.java?rev=1425347&r1=1425346&r2=1425347&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/BlogEntrySummary.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/BlogEntrySummary.java Sat Dec 22 21:25:57 2012
@@ -42,8 +42,10 @@ public class BlogEntrySummary extends Ab
String mod = DOMUtils.getChildContent(root, "publishDate");
published = DatatypeFactory.newInstance().newXMLGregorianCalendar(mod);
- String v = DOMUtils.getChildContent(root, "version");
- version = (v == null) ? "0" : v;
+
+ // XXX: version is not included with BlogEntrySummary so force
+ // unqiue version so that all blog entries get rendered
+ version = String.valueOf(System.currentTimeMillis());
}
public String getDirectory() {
Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1425347&r1=1425346&r2=1425347&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Sat Dec 22 21:25:57 2012
@@ -275,13 +275,16 @@ public class SiteExporter implements Run
break;
}
}
+
if (forceAll) {
modifiedPages.clear();
modifiedPages.addAll(pages.values());
+
+ modifiedBlog.clear();
+ modifiedBlog.addAll(blog.values());
}
-
- if (!modifiedPages.isEmpty()) {
+ if (!modifiedPages.isEmpty() || !modifiedBlog.isEmpty()) {
renderBlog();
renderPages();
saveCache();
@@ -304,15 +307,15 @@ public class SiteExporter implements Run
List<Element> els = DOMUtils.getChildrenWithName(doc.getDocumentElement(),
"http://www.w3.org/2005/Atom",
"entry");
- //XMLUtils.printDOM(doc);
+ // XMLUtils.printDOM(doc);
for (Element el : els) {
Element e2 = DOMUtils.getFirstChildWithName(el, "http://www.w3.org/2005/Atom", "updated");
String val = DOMUtils.getContent(e2);
XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(val);
e2 = DOMUtils.getFirstChildWithName(el, "http://www.w3.org/2005/Atom", "title");
String title = DOMUtils.getContent(e2);
- Page p = findPage(title);
+ Page p = findPage(title);
if (p != null) {
//found a modified page - need to rebuild
if (cal.compare(p.getModifiedTime()) > 0) {
@@ -320,8 +323,15 @@ public class SiteExporter implements Run
return false;
}
} else {
- System.out.println("(" + spaceKey + ") Did not find page for: " + title);
- return false;
+ BlogEntrySummary entry = findBlogEntry(title);
+ if (entry != null) {
+ // we don't have modified date so just assume it's modified
+ System.out.println("(" + spaceKey + ") Changed blog page found: " + title);
+ return false;
+ } else {
+ System.out.println("(" + spaceKey + ") Did not find page for: " + title);
+ return false;
+ }
}
}
@@ -536,21 +546,13 @@ public class SiteExporter implements Run
}
}
public Page findPage(String title) throws Exception {
- for (Page p : pages.values()) {
- if (title.equals(p.getTitle())) {
- return p;
- }
- }
- return null;
+ return (Page) findByTitle(title, pages.values());
}
+
public Page findPageByURL(String url) throws Exception {
- for (Page p : pages.values()) {
- if (p.getURL().endsWith(url)) {
- return p;
- }
- }
- return null;
+ return (Page) findByURL(url, pages.values());
}
+
public Page findPageByID(String id) {
for (Page p : pages.values()) {
if (p.getId().equals(id)) {
@@ -765,9 +767,7 @@ public class SiteExporter implements Run
if (nd instanceof Element) {
BlogEntrySummary entry = new BlogEntrySummary((Element)nd);
BlogEntrySummary oldEntry = blog.put(entry.getId(), entry);
- System.out.println(entry + " " + oldEntry);
if (oldEntry == null || !oldEntry.getVersion().equals(entry.getVersion())) {
- System.out.println("modified: " + entry);
modifiedBlog.add(entry);
}
oldBlog.remove(entry.getId());
@@ -789,8 +789,16 @@ public class SiteExporter implements Run
}
}
+ public BlogEntrySummary findBlogEntry(String title) throws Exception {
+ return (BlogEntrySummary) findByTitle(title, blog.values());
+ }
+
public BlogEntrySummary findBlogEntryByURL(String url) throws Exception {
- for (BlogEntrySummary p : blog.values()) {
+ return (BlogEntrySummary) findByURL(url, blog.values());
+ }
+
+ private AbstractPage findByURL(String url, Collection<? extends AbstractPage> pages) throws Exception {
+ for (AbstractPage p : pages) {
if (p.getURL().endsWith(url)) {
return p;
}
@@ -798,6 +806,15 @@ public class SiteExporter implements Run
return null;
}
+ private AbstractPage findByTitle(String title, Collection<? extends AbstractPage> pages) throws Exception {
+ for (AbstractPage p : pages) {
+ if (title.equals(p.getTitle())) {
+ return p;
+ }
+ }
+ return null;
+ }
+
public void loadPages() throws Exception {
Document doc = XMLUtils.newDocument();
Element el = doc.createElementNS(SOAPNS, "ns1:getPages");
@@ -910,7 +927,7 @@ public class SiteExporter implements Run
}
return space;
}
-
+
public Future<?> loadPage(Element pageSumEl,
final Set<String> allPages,
final Set<Page> newPages) throws Exception {