Author: ajaquith
Date: Sat Jan 30 15:27:15 2010
New Revision: 904791
URL: http://svn.apache.org/viewvc?rev=904791&view=rev
Log:
Added methods getCreated() and getChangeNote() to WikiPage and JCRWikiPage.
Fixed bug in ContentManager that was preventing creation and modification times
from being correctly set upon save.
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java?rev=904791&r1=904790&r2=904791&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java
(original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java Sat Jan
30 15:27:15 2010
@@ -110,11 +110,21 @@
public Serializable removeAttribute( String key );
/**
- * Returns the date when this page was last modified.
- * If the page has never been modified (because it has never
+ * Returns the date when this page was first saved.
+ * If the page has not been created (because it has never
* been saved, for example), this method returns {...@code null}.
*
- * @return The last modification date
+ * @return the first save date
+ */
+ public Date getCreated();
+
+ /**
+ * Returns the date when this page was last modified, including
+ * the first time the page was saved. If the page has never
+ * been modified (because it has never been saved, for example),
+ * this method returns {...@code null}.
+ *
+ * @return the last modification date
*/
public Date getLastModified();
@@ -278,6 +288,12 @@
public List<WikiPage> getChildren() throws ProviderException;
/**
+ * Returns the change note for this page version.
+ * @return the change note, or {...@code null} if not provided
+ */
+ public String getChangeNote() throws ProviderException;
+
+ /**
* Returns true, if this page is an attachment (that is, does not
* contain wikimarkup and has a parent page).
* <p>
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java?rev=904791&r1=904790&r2=904791&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/ContentManager.java
Sat Jan 30 15:27:15 2010
@@ -505,10 +505,12 @@
int version = page.getVersion();
+ Calendar timestamp = Calendar.getInstance();
if( isNew( nd ) )
{
nd.setProperty( JCRWikiPage.ATTR_VERSION, 1 );
- nd.setProperty( JCRWikiPage.ATTR_CREATED, Calendar.getInstance() );
+ nd.setProperty( JCRWikiPage.ATTR_CREATED, timestamp );
+ nd.setProperty( JCRWikiPage.LAST_MODIFIED, timestamp );
// New node, so nothing to check in
nd.getParent().save();
@@ -520,6 +522,7 @@
checkin( getJCRPath( path ), version );
nd.setProperty( JCRWikiPage.ATTR_VERSION, version+1 );
+ nd.setProperty( JCRWikiPage.LAST_MODIFIED, timestamp );
nd.save();
}
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java
URL:
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java?rev=904791&r1=904790&r2=904791&view=diff
==============================================================================
---
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java
(original)
+++
incubator/jspwiki/trunk/src/java/org/apache/wiki/content/jcr/JCRWikiPage.java
Sat Jan 30 15:27:15 2010
@@ -56,7 +56,7 @@
private static final long serialVersionUID = 1L;
/** The name of the attribute that stores the last-modified timestamp. */
- private static final String LAST_MODIFIED = "wiki:lastModified";
+ public static final String LAST_MODIFIED = "wiki:lastModified";
private static final String AUTHOR = "wiki:author";
@@ -132,6 +132,25 @@
}
/**
+ * {...@inheritdoc}
+ */
+ public String getChangeNote() throws ProviderException
+ {
+ try
+ {
+ if ( getJCRNode().hasProperty( WikiPage.CHANGENOTE ) )
+ {
+ return getAttribute( WikiPage.CHANGENOTE ).toString();
+ }
+ }
+ catch( RepositoryException e )
+ {
+ throw new ProviderException( e.getMessage(), e );
+ }
+ return null;
+ }
+
+ /**
* Returns the JCR Node which backs this WikiPage implementation.
*
* @return The JCR Node
@@ -776,6 +795,25 @@
return (JCRWikiPage)p;
}
+
+ /**
+ * {...@inheritdoc}
+ */
+ public Date getCreated()
+ {
+ try
+ {
+ if ( getJCRNode().hasProperty( ATTR_CREATED ) )
+ {
+ return getJCRNode().getProperty( ATTR_CREATED
).getDate().getTime();
+ }
+ }
+ catch( RepositoryException e )
+ {
+ log.warn( "RepositoryException while getting created : " + e );
+ }
+ return null;
+ }
public JCRWikiPage getCurrentVersion() throws ProviderException
{