jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajaqu...@apache.org
Subject svn commit: r713635 - in /incubator/jspwiki/trunk/src/org/apache/jspwiki/api: AbstractContext.java ActionContext.java WikiContext.java WikiRenderer.java
Date Thu, 13 Nov 2008 04:36:29 GMT
Author: ajaquith
Date: Wed Nov 12 20:36:29 2008
New Revision: 713635

URL: http://svn.apache.org/viewvc?rev=713635&view=rev
Log:
Several API interface changes. AbstractContext renamed to ActionContext; several methods pushed
down to WikiContext subinterface. Stripes branch "doc/README - Stripes Migration" document
updated to reflect these changes. Note to Janne: "ActionContext" is the same as the "RequestState"
interface we discussed.

Added:
    incubator/jspwiki/trunk/src/org/apache/jspwiki/api/ActionContext.java
      - copied, changed from r712925, incubator/jspwiki/trunk/src/org/apache/jspwiki/api/AbstractContext.java
Removed:
    incubator/jspwiki/trunk/src/org/apache/jspwiki/api/AbstractContext.java
Modified:
    incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiContext.java
    incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiRenderer.java

Copied: incubator/jspwiki/trunk/src/org/apache/jspwiki/api/ActionContext.java (from r712925,
incubator/jspwiki/trunk/src/org/apache/jspwiki/api/AbstractContext.java)
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/jspwiki/api/ActionContext.java?p2=incubator/jspwiki/trunk/src/org/apache/jspwiki/api/ActionContext.java&p1=incubator/jspwiki/trunk/src/org/apache/jspwiki/api/AbstractContext.java&r1=712925&r2=713635&rev=713635&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/jspwiki/api/AbstractContext.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/jspwiki/api/ActionContext.java Wed Nov 12 20:36:29
2008
@@ -20,18 +20,15 @@
  */
 package org.apache.jspwiki.api;
 
-import java.io.IOException;
-import java.security.Permission;
 import java.security.Principal;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 /**
- *  The AbstractContext represents a request lifecycle.  It is valid throughout
+ *  The ActionContext represents a request lifecycle.  It is valid throughout
  *  the request, and gives access to innards of JSPWiki.
  *  <p>
  *  This mostly replaces the old WikiContext class.  The reason is that WikiContext
@@ -43,25 +40,10 @@
  *  or filters).
  */
 // FIXME: This might be the wrong name.
-public interface AbstractContext
+public interface ActionContext
 {
     
     /**
-     *  Returns the name of the current template which is in use.
-     *  
-     *  @return The template name
-     */
-    // FIXME: Would it be better to return an object (e.g. WikiTemplate?)
-    public String getContentTemplate();
-    
-    /**
-     *  Returns the name of the top-level JSP file that this one refers to
-     *  @return The JSP file name
-     */
-    // FIXME: Shouldn't this be really just a pointer to the bean?
-    public String getJSP();
-    
-    /**
      *  Returns the handling engine.
      *
      *  @return The wikiengine owning this context.
@@ -115,22 +97,6 @@
      */
     public HttpServletRequest getHttpRequest();
 
-
-    /**
-     * Returns the target of this wiki context: a page, group name or JSP. If
-     * the associated Command is a PageCommand, this method returns the page's
-     * name. Otherwise, this method delegates to the associated Command's
-     * {@link com.ecyrd.jspwiki.ui.Command#getName()} method. Calling classes
-     * can rely on the results of this method for looking up canonically-correct
-     * page or group names. Because it does not automatically assume that the
-     * wiki context is a PageCommand, calling this method is inherently safer
-     * than calling <code>getPage().getName()</code>.
-     * @return the name of the target of this wiki context
-     * @see com.ecyrd.jspwiki.ui.PageCommand#getName()
-     * @see com.ecyrd.jspwiki.ui.GroupCommand#getName()
-     */
-    public String getName();
-
     /**
      *  Gets the template that is to be used throughout this request.
      *  @since 2.1.15.
@@ -150,41 +116,6 @@
     public Principal getCurrentUser();
 
     /**
-     *  A shortcut to generate a VIEW url.
-     *
-     *  @param page The page to which to link.
-     *  @return An URL to the page.  This honours the current absolute/relative setting.
-     */
-    // FIXME: Better to create a new URL creation class, which is WikiContext-specific?
-    public String getViewURL( String page );
-
-    /**
-     *  Creates an URL for the given request context.
-     *
-     *  @param context e.g. WikiContext.EDIT
-     *  @param page The page to which to link
-     *  @return An URL to the page, honours the absolute/relative setting in jspwiki.properties
-     */
-    public String getURL( String context,
-                          String page );
-
-    /**
-     *  Returns an URL from a page. It this WikiContext instance was constructed
-     *  with an actual HttpServletRequest, we will attempt to construct the
-     *  URL using HttpUtil, which preserves the HTTPS portion if it was used.
-     *
-     *  @param context The request context (e.g. WikiContext.UPLOAD)
-     *  @param page    The page to which to link
-     *  @param params  A list of parameters, separated with "&amp;"
-     *
-     *  @return An URL to the given context and page.
-     */
-    public String getURL( String context,
-                          String page,
-                          String params );
-
-
-    /**
      *  Returns a shallow clone of the WikiContext.
      *
      *  @since 2.1.37.
@@ -203,56 +134,6 @@
     public WikiSession getWikiSession();
 
     /**
-     * Returns the permission required to successfully execute this context.
-     * For example, the a wiki context of VIEW for a certain page means that
-     * the PagePermission "view" is required for the page. In some cases, no
-     * particular permission is required, in which case a dummy permission will
-     * be returned ({@link java.util.PropertyPermission}<code> "os.name",
-     * "read"</code>). This method is guaranteed to always return a valid,
-     * non-null permission.
-     * @return the permission
-     * @since 2.4
-     */
-    public Permission requiredPermission();
-
-
-    /**
-     * Checks whether the current user has access to this wiki context,
-     * by obtaining the required Permission ({@link #requiredPermission()})
-     * and delegating the access check to
-     * {@link com.ecyrd.jspwiki.auth.AuthorizationManager#checkPermission(WikiSession, Permission)}.
-     * If the user is allowed, this method returns <code>true</code>;
-     * <code>false</code> otherwise. If access is allowed,
-     * the wiki context will be added to the request as an attribute
-     * with the key name {@link com.ecyrd.jspwiki.tags.WikiTagBase#ATTR_CONTEXT}.
-     * Note that this method will automatically redirect the user to
-     * a login or error page, as appropriate, if access fails. This is
-     * NOT guaranteed to be default behavior in the future.
-     * @param response the http response
-     * @return the result of the access check
-     * @throws IOException In case something goes wrong
-     */
-    // FIXME: Is this the correct place really for this?
-    public boolean hasAccess( HttpServletResponse response ) throws IOException;
-
-    /**
-     * Checks whether the current user has access to this wiki context (and
-     * optionally redirects if not), by obtaining the required Permission ({@link #requiredPermission()})
-     * and delegating the access check to
-     * {@link com.ecyrd.jspwiki.auth.AuthorizationManager#checkPermission(WikiSession, Permission)}.
-     * If the user is allowed, this method returns <code>true</code>;
-     * <code>false</code> otherwise. If access is allowed,
-     * the wiki context will be added to the request as attribute
-     * with the key name {@link com.ecyrd.jspwiki.tags.WikiTagBase#ATTR_CONTEXT}.
-     * @return the result of the access check
-     * @param response The servlet response object
-     * @param redirect If true, makes an automatic redirect to the response
-     * @throws IOException If something goes wrong
-     */
-    // FIXME: Is this the correct place really for this?
-    public boolean hasAccess( HttpServletResponse response, boolean redirect ) throws IOException;
-
-    /**
      *  Locates the i18n ResourceBundle given.  This method interprets
      *  the request locale, and uses that to figure out which language the
      *  user wants.

Modified: incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiContext.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiContext.java?rev=713635&r1=713634&r2=713635&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiContext.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiContext.java Wed Nov 12 20:36:29
2008
@@ -20,6 +20,11 @@
  */
 package org.apache.jspwiki.api;
 
+import java.io.IOException;
+import java.security.Permission;
+
+import javax.servlet.http.HttpServletResponse;
+
 
 /**
  *  The WikiContext represents a request which targets a WikiPage
@@ -28,7 +33,7 @@
  *  This class would be better named as "PageRequestContext" or something,
  *  but we need to keep at least some similarity with the 2.x API...
  */
-public interface WikiContext extends AbstractContext
+public interface WikiContext extends ActionContext
 {
 
 
@@ -73,24 +78,95 @@
     public WikiPage getRealPage();
 
     /**
-     *  Figure out to which page we are really going to.  Considers
-     *  special page names from the jspwiki.properties, and possible aliases.
-     *  This method forwards requests to
-     *  {@link com.ecyrd.jspwiki.ui.CommandResolver#getSpecialPageReference(String)}.
-     *  @return A complete URL to the new page to redirect to
-     *  @since 2.2
+     *  Returns the page that is being handled.
+     *
+     *  @return the page which was fetched.
      */
+    public WikiPage getPage();
 
-    // FIXME: Probably not needed for 3.0?
-    public String getRedirectURL();
+    /**
+     * Returns the target of this wiki context: a page, group name or JSP. If
+     * the associated Command is a PageCommand, this method returns the page's
+     * name. Otherwise, this method delegates to the associated Command's
+     * {@link com.ecyrd.jspwiki.ui.Command#getName()} method. Calling classes
+     * can rely on the results of this method for looking up canonically-correct
+     * page or group names. Because it does not automatically assume that the
+     * wiki context is a PageCommand, calling this method is inherently safer
+     * than calling <code>getPage().getName()</code>.
+     * @return the name of the target of this wiki context
+     * @see com.ecyrd.jspwiki.ui.PageCommand#getName()
+     * @see com.ecyrd.jspwiki.ui.GroupCommand#getName()
+     */
+    public String getName();
 
+    /**
+     *  Creates an URL for the given request context.
+     *
+     *  @param context e.g. WikiContext.EDIT
+     *  @param page The page to which to link
+     *  @return An URL to the page, honours the absolute/relative setting in jspwiki.properties
+     */
+    public String getURL( String context,
+                          String page );
 
     /**
-     *  Returns the page that is being handled.
+     *  Returns an URL from a page. It this WikiContext instance was constructed
+     *  with an actual HttpServletRequest, we will attempt to construct the
+     *  URL using HttpUtil, which preserves the HTTPS portion if it was used.
      *
-     *  @return the page which was fetched.
+     *  @param context The request context (e.g. WikiContext.UPLOAD)
+     *  @param page    The page to which to link
+     *  @param params  A list of parameters, separated with "&amp;"
+     *
+     *  @return An URL to the given context and page.
      */
-    public WikiPage getPage();
+    public String getURL( String context,
+                          String page,
+                          String params );
+
+    /**
+     *  A shortcut to generate a VIEW url.
+     *
+     *  @param page The page to which to link.
+     *  @return An URL to the page.  This honours the current absolute/relative setting.
+     */
+    // FIXME: Better to create a new URL creation class, which is WikiContext-specific?
+    public String getViewURL( String page );
+
+    /**
+     * Checks whether the current user has access to this wiki context,
+     * by obtaining the required Permission ({@link #requiredPermission()})
+     * and delegating the access check to
+     * {@link com.ecyrd.jspwiki.auth.AuthorizationManager#checkPermission(WikiSession, Permission)}.
+     * If the user is allowed, this method returns <code>true</code>;
+     * <code>false</code> otherwise. If access is allowed,
+     * the wiki context will be added to the request as an attribute
+     * with the key name {@link com.ecyrd.jspwiki.tags.WikiTagBase#ATTR_CONTEXT}.
+     * Note that this method will automatically redirect the user to
+     * a login or error page, as appropriate, if access fails. This is
+     * NOT guaranteed to be default behavior in the future.
+     * @param response the http response
+     * @return the result of the access check
+     * @throws IOException In case something goes wrong
+     */
+    // FIXME: Is this the correct place really for this?
+    public boolean hasAccess( HttpServletResponse response ) throws IOException;
 
+    /**
+     * Checks whether the current user has access to this wiki context (and
+     * optionally redirects if not), by obtaining the required Permission ({@link #requiredPermission()})
+     * and delegating the access check to
+     * {@link com.ecyrd.jspwiki.auth.AuthorizationManager#checkPermission(WikiSession, Permission)}.
+     * If the user is allowed, this method returns <code>true</code>;
+     * <code>false</code> otherwise. If access is allowed,
+     * the wiki context will be added to the request as attribute
+     * with the key name {@link com.ecyrd.jspwiki.tags.WikiTagBase#ATTR_CONTEXT}.
+     * @return the result of the access check
+     * @param response The servlet response object
+     * @param redirect If true, makes an automatic redirect to the response
+     * @throws IOException If something goes wrong
+     */
+    // FIXME: Is this the correct place really for this?
+    public boolean hasAccess( HttpServletResponse response, boolean redirect ) throws IOException;
 
 }

Modified: incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiRenderer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiRenderer.java?rev=713635&r1=713634&r2=713635&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiRenderer.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/jspwiki/api/WikiRenderer.java Wed Nov 12 20:36:29
2008
@@ -51,11 +51,11 @@
     /**
      *  Returns the rendered content.
      */
-    public InputStream render( AbstractContext context, String content );
+    public InputStream render( ActionContext context, String content );
     
     /**
      *  Returns the rendered content as a String.  This is just a simplification
      *  for those content types where it can be rendered as a String.
      */
-    public String renderString( AbstractContext context, String content );
+    public String renderString( ActionContext context, String content );
 }



Mime
View raw message