You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2009/05/23 15:29:21 UTC
svn commit: r777915 - in /incubator/jspwiki/trunk/src/java/org/apache/wiki:
JCRWikiPage.java api/WikiPage.java
Author: ajaquith
Date: Sat May 23 13:29:21 2009
New Revision: 777915
URL: http://svn.apache.org/viewvc?rev=777915&view=rev
Log:
Minor enhancement to JCRWikiPage: now implements getContentAsStream(). Also, Javadocs and field m_name tweaked to reflect WikiName-->WikiPath renaming. The method getContentType() was pulled up from Attachment into the WikiPage interface to prevent need to special-case.
Modified:
incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/api/WikiPage.java
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java?rev=777915&r1=777914&r2=777915&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/JCRWikiPage.java Sat May 23 13:29:21 2009
@@ -63,7 +63,7 @@
public static final String CONTENTTYPE = "wiki:contentType";
- private WikiPath m_name;
+ private WikiPath m_path;
private WikiEngine m_engine;
private String m_jcrPath = null;
@@ -71,11 +71,11 @@
* Use {@link WikiEngine#createPage(WikiPath)} instead.
* @deprecated
*/
- public JCRWikiPage( WikiEngine engine, WikiPath name )
+ public JCRWikiPage( WikiEngine engine, WikiPath path )
{
m_engine = engine;
- m_name = name;
- m_jcrPath = ContentManager.getJCRPath( name );
+ m_path = path;
+ m_jcrPath = ContentManager.getJCRPath( path );
}
/**
@@ -108,7 +108,7 @@
{
m_engine = engine;
m_jcrPath = node.getPath();
- m_name = name;
+ m_path = name;
}
public Node getJCRNode() throws RepositoryException
@@ -121,7 +121,7 @@
*/
public String getName()
{
- return m_name.getPath();
+ return m_path.getPath();
}
/* (non-Javadoc)
@@ -129,7 +129,7 @@
*/
public WikiPath getPath()
{
- return m_name;
+ return m_path;
}
/* (non-Javadoc)
@@ -242,7 +242,8 @@
return null;
}
- /* (non-Javadoc)
+ /**
+ * {@inheritDoc}
* @see org.apache.wiki.WikiPage#getLastModified()
*/
public Date getLastModified()
@@ -415,7 +416,7 @@
// FIXME: Should we rename this method?
public String getWiki()
{
- return m_name.getSpace();
+ return m_path.getSpace();
}
/* (non-Javadoc)
@@ -423,7 +424,7 @@
*/
public String toString()
{
- return "WikiPage ["+m_name+",ver="+getVersion()+",mod="+getLastModified()+"]";
+ return "WikiPage ["+m_path+",ver="+getVersion()+",mod="+getLastModified()+"]";
}
/* (non-Javadoc)
@@ -431,7 +432,7 @@
*/
public Object clone()
{
- JCRWikiPage p = new JCRWikiPage( m_engine, m_name );
+ JCRWikiPage p = new JCRWikiPage( m_engine, m_path );
return p;
}
@@ -479,28 +480,40 @@
*/
public int hashCode()
{
- return m_name.hashCode() * getVersion();
+ return m_path.hashCode() * getVersion();
}
- public InputStream getContentAsStream()
+ public InputStream getContentAsStream() throws ProviderException
{
- // TODO Auto-generated method stub
+ try
+ {
+ Property p = getJCRNode().getProperty( ATTR_CONTENT );
+
+ return p.getStream();
+ }
+ catch( PathNotFoundException e )
+ {
+ }
+ catch( RepositoryException e )
+ {
+ throw new ProviderException("Unable to get property",e);
+ }
return null;
}
- public String getContentType() throws ProviderException
+ public String getContentType()
{
return (String)getAttribute( CONTENTTYPE );
}
public List<WikiPath> getReferrers() throws ProviderException
{
- return m_engine.getReferenceManager().getReferredBy( m_name );
+ return m_engine.getReferenceManager().getReferredBy( m_path );
}
public List<WikiPath> getRefersTo() throws ProviderException
{
- return m_engine.getReferenceManager().getRefersTo( m_name );
+ return m_engine.getReferenceManager().getRefersTo( m_path );
}
@@ -569,13 +582,17 @@
public WikiPage getParent() throws PageNotFoundException, ProviderException
{
- return m_engine.getContentManager().getPage( m_name.getParent() );
+ return m_engine.getContentManager().getPage( m_path.getParent() );
}
+ /**
+ * Returns the file name of the WikiPage. For both attachments and wiki pages,
+ * this is the name portion of the WikiPath that comes after the last trailing slash.
+ * It is equal to the value of {@link WikiPath#getName()}.
+ */
public String getFileName()
{
- // TODO Auto-generated method stub
- return null;
+ return m_path.getName();
}
public boolean isCacheable()
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=777915&r1=777914&r2=777915&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 May 23 13:29:21 2009
@@ -27,6 +27,7 @@
import java.util.Map;
import org.apache.wiki.auth.acl.Acl;
+import org.apache.wiki.content.ContentManager;
import org.apache.wiki.content.PageNotFoundException;
import org.apache.wiki.content.WikiPath;
import org.apache.wiki.providers.ProviderException;
@@ -209,6 +210,16 @@
public InputStream getContentAsStream() throws ProviderException;
/**
+ * Returns the MIME type of the attachment. Wiki markup will always return
+ * content type <code>{@link ContentManager#JSPWIKI_CONTENT_TYPE}</code>.
+ * Other WikiPage sub-interfaces, for example
+ * {@link org.apache.wiki.attachment.Attachment} may elect to return different
+ * content types.
+ * @return the attachment type
+ */
+ public String getContentType();
+
+ /**
* Stores the state of the page, creating a new version in the
* repository. Implementations must, at least, call
* {@link org.apache.wiki.content.ContentManager#save(WikiPage)}