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/04 17:55:06 UTC
svn commit: r1428974 - in
/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki:
BlogEntrySummary.java SiteExporter.java
Author: gawor
Date: Fri Jan 4 16:55:06 2013
New Revision: 1428974
URL: http://svn.apache.org/viewvc?rev=1428974&view=rev
Log:
ensure we don't re-render blog pages if nothing really has changed
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=1428974&r1=1428973&r2=1428974&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 Fri Jan 4 16:55:06 2013
@@ -35,17 +35,17 @@ public class BlogEntrySummary extends Ab
private static final long serialVersionUID = 1L;
final XMLGregorianCalendar published;
- final String version;
+
+ // BlogEntrySummary does not have version field but the BlogEntry does.
+ // We load and set the version separately. It will be used to decide
+ // whether the blog entry needs to be re-rendered or not.
+ int version;
public BlogEntrySummary(Element root) throws Exception {
super(root);
String mod = DOMUtils.getChildContent(root, "publishDate");
published = DatatypeFactory.newInstance().newXMLGregorianCalendar(mod);
-
- // 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() {
@@ -65,10 +65,14 @@ public class BlogEntrySummary extends Ab
return builder.toString();
}
- public String getVersion() {
+ public int getVersion() {
return version;
}
+ void setVersion(int version) {
+ this.version = version;
+ }
+
public XMLGregorianCalendar getPublished() {
return published;
}
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=1428974&r1=1428973&r2=1428974&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 Fri Jan 4 16:55:06 2013
@@ -326,6 +326,7 @@ public class SiteExporter implements Run
BlogEntrySummary entry = findBlogEntry(title);
if (entry != null) {
// we don't have modified date so just assume it's modified
+ // we'll use version number to actually figure out if page is modified or not
System.out.println("(" + spaceKey + ") Changed blog page found: " + title);
return false;
} else {
@@ -748,6 +749,24 @@ public class SiteExporter implements Run
}
}
+ public int getBlogVersion(String pageId) throws Exception {
+ Document doc = XMLUtils.newDocument();
+ Element el = doc.createElementNS(SOAPNS, "ns1:getBlogEntry");
+ Element el2 = doc.createElement("in0");
+ el.appendChild(el2);
+ el2.setTextContent(loginToken);
+ el2 = doc.createElement("in1");
+ el.appendChild(el2);
+ el2.setTextContent(pageId);
+ doc.appendChild(el);
+ doc = getDispatch().invoke(doc);
+
+ Node nd = doc.getDocumentElement().getFirstChild();
+
+ String version = DOMUtils.getChildContent(nd, "version");
+ return Integer.parseInt(version);
+ }
+
public void loadBlog() throws Exception {
Document doc = XMLUtils.newDocument();
Element el = doc.createElementNS(SOAPNS, "ns1:getBlogEntries");
@@ -766,8 +785,9 @@ public class SiteExporter implements Run
while (nd != null) {
if (nd instanceof Element) {
BlogEntrySummary entry = new BlogEntrySummary((Element)nd);
+ entry.setVersion(getBlogVersion(entry.id));
BlogEntrySummary oldEntry = blog.put(entry.getId(), entry);
- if (oldEntry == null || !oldEntry.getVersion().equals(entry.getVersion())) {
+ if (oldEntry == null || oldEntry.getVersion() != entry.getVersion()) {
modifiedBlog.add(entry);
}
oldBlog.remove(entry.getId());