Return-Path: Delivered-To: apmail-incubator-jspwiki-commits-archive@locus.apache.org Received: (qmail 25060 invoked from network); 13 Nov 2008 04:37:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Nov 2008 04:37:20 -0000 Received: (qmail 71704 invoked by uid 500); 13 Nov 2008 04:37:28 -0000 Delivered-To: apmail-incubator-jspwiki-commits-archive@incubator.apache.org Received: (qmail 71693 invoked by uid 500); 13 Nov 2008 04:37:28 -0000 Mailing-List: contact jspwiki-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jspwiki-dev@incubator.apache.org Delivered-To: mailing list jspwiki-commits@incubator.apache.org Received: (qmail 71682 invoked by uid 99); 13 Nov 2008 04:37:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 12 Nov 2008 20:37:28 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Nov 2008 04:36:16 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 1043A238893B; Wed, 12 Nov 2008 20:36:30 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: jspwiki-commits@incubator.apache.org From: ajaquith@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081113043630.1043A238893B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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. *

* 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 getPage().getName(). - * @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 "&" - * - * @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} "os.name", - * "read"). 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 true; - * false 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 true; - * false 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 getPage().getName(). + * @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 "&" + * + * @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 true; + * false 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 true; + * false 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 ); }