001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portal.wsrp;
023:
024: /**
025: * <p>This class provides constants used in the context of URL rewriting.</p>
026: *
027: * @author <a href="mailto:chris.laprun@jboss.com">Chris Laprun</a>
028: * @version $Revision: 8784 $
029: * @since 2.4
030: */
031: public final class WSRPRewritingConstants {
032:
033: private static final String WSRP_REWRITE = "wsrp_rewrite";
034:
035: /**
036: * 10.2.1 <p>All portlet URLs (i.e. those the Consumer needs to rewrite) are demarcated in the markup by a token
037: * (wsrp_rewrite) both at the start (with a "?" appended to clearly delimit the start of the name/value pairs).</p>
038: */
039: public static final String BEGIN_WSRP_REWRITE = WSRP_REWRITE + "?";
040:
041: public static final int WSRP_REWRITE_PREFIX_LENGTH = 13;
042:
043: /**
044: * 10.2.1 <p>All portlet URLs (i.e. those the Consumer needs to rewrite) are demarcated in the markup by a token
045: * (wsrp_rewrite) at the end (proceeded by a "/" to form the end token) of the URL declaration.</p>
046: */
047: public static final String END_WSRP_REWRITE = "/" + WSRP_REWRITE;
048:
049: public static final int WSRP_REWRITE_SUFFIX_LENGTH = 13;
050:
051: /**
052: * 10.2.1.1 wsrp-urlType <p>This parameter MUST be specified first when using the Consumer URL rewriting template and
053: * the value selected from the following definitions. Well-known portlet URL parameter names that are valid for only
054: * one wsrp-urlType are described relative to that wsrp-urlType while the remainder are described later.</p>
055: */
056: public static final String URL_TYPE_NAME = "wsrp-urlType";
057:
058: /**
059: * 10.2.1.1.1 wsrp-urlType = blockingAction <p>Activation of the URL will result in an invocation of
060: * performBlockingInteraction() on the Portlet that generated the markup. All form parameters, submitted as query
061: * string parameters using the HTTP GET method, that are not used to encode parameters defined by this specification
062: * MUST be passed to performBlockingInteraction() as formParameters.</p>
063: */
064: public static final String URL_TYPE_BLOCKING_ACTION = "blockingAction";
065:
066: /**
067: * 10.2.1.1.2 wsrp-urlType = render <p>Activation of the URL will result in an invocation of getMarkup(). This
068: * mechanism permits a Portlet"s markup to contain URLs, which do not involve changes to local state, to avoid the
069: * overhead of two-step processing by directly invoking getMarkup(). The URL MAY specify a wsrp-navigationalState
070: * portlet URL parameter, whose value the Consumer MUST supply in the navigationalState field of the MarkupParams
071: * structure. If there is no such portlet URL parameter, the Consumer MUST NOT supply a value for this field.</p>
072: */
073: public static final String URL_TYPE_RENDER = "render";
074:
075: /**
076: * 10.2.1.1.3 wsrp-urlType = resource <p>Activation of the URL will result in the Consumer acting as a gateway to the
077: * underlying resource, possibly in a cached manner, and returning it to the user-agent. The URL for the resource
078: * (including any query string parameters) is encoded as the value of the wsrp-url parameter. When a portlet URL
079: * specifies "resource" for the wsrp-urlType portlet URL parameter, both the wsrp-url and wsrp-requiresRewrite
080: * portlet URL parameters MUST also be specified. If the Portlet needs to share data with the referenced resource, it
081: * can exploit the cookie support defined in section 10.4.</p>
082: */
083: public static final String URL_TYPE_RESOURCE = "resource";
084:
085: /**
086: * 10.2.1.1.3.1 wsrp-url <p>This parameter provides the actual URL to the resource. Note that this needs to be an
087: * absolute URL as the resource fetch will have no base for use in fetching a relative URL. Also note that since this
088: * resource URL will appear as a parameter value, it has to be strictly encoded (i.e. "&", "=", "/", and "?" need to
089: * be url-escaped) so that special URL characters do not invalidate the processing of the enclosing URL. Consumers
090: * are encouraged to use the same communication style (e.g. HTTP Get or Post) for retrieving the resource as was used
091: * in requesting the resource by the user-agent.</p>
092: */
093: public static final String RESOURCE_URL = "wsrp-url";
094:
095: /**
096: * 10.2.1.1.3.2 wsrp-requiresRewrite <p>This boolean informs the Consumer that the resource needs to be parsed for
097: * URL rewriting. Normally this means that there are names that will be cross-referenced between the markup and this
098: * resource (e.g. JavaScript references). Note that this means the Consumer needs to deal with rewriting unique
099: * "namespaced" names in a set of documents, rather than treating each document individually. Processing such
100: * resources in a manner that allows caching of the resulting resource by the End-User"s user-agent can improve the
101: * performance of the aggregated page for the End-User. In particular, Consumers can process namespace rewriting by
102: * using a prefix that is unique to the user/Portlet pair provided any such prefix is held constant for the duration
103: * of use within the user"s session with the Consumer of any one Portlet.</p>
104: */
105: public static final String RESOURCE_REQUIRES_REWRITE = "wsrp-requiresRewrite";
106:
107: /**
108: * 10.2.1.2 wsrp-navigationalState <p>The value of this portlet URL parameter defines the navigational state the
109: * Consumer MUST send to the Producer when the URL is activated. If this parameter is missing, the Consumer MUST NOT
110: * supply the navigationalState field of the MarkupParams.</p>
111: */
112: public static final String NAVIGATIONAL_STATE = "wsrp-navigationalState";
113:
114: /**
115: * 10.2.1.3 wsrp-interactionState <p>The value of this portlet URL parameter defines the interaction state the
116: * Consumer MUST send to the Producer when the URL is activated. Tree.If this parameter is missing, the Consumer MUST
117: * NOT supply the interactionState field of the InteractionParams structure.</p>
118: */
119: public static final String INTERACTION_STATE = "wsrp-interactionState";
120:
121: /**
122: * 10.2.1.4 wsrp-mode <p>Activating this URL includes a request to change the mode parameter in MarkupParams into the
123: * mode specified as the value for this portlet URL parameter. The value for wsrp-mode MUST be one of the modes
124: * detailed in section 6.8 or a custom mode the Consumer specified as supported during registration. The wsrp-mode
125: * portlet URL parameter MAY be used whenever the wsrp-urlType portlet URL parameter has a value of "blockingAction"
126: * or "render".</p>
127: */
128: public static final String MODE = "wsrp-mode";
129:
130: /**
131: * 10.2.1.5 wsrp-windowState <p>Activating this URL includes a request to change the windowState parameter in
132: * MarkupParams into the window state specified as the value for this portlet URL parameter. The value for wsrp-
133: * windowState MUST be one of the values detailed in section 6.9 or a custom window state the Consumer specified as
134: * supported during registration. The wsrp-windowState portlet URL parameter MAY be used whenever the wsrp-urlType
135: * portlet URL parameter has a value of "blockingAction" or "render".</p>
136: */
137: public static final String WINDOW_STATE = "wsrp-windowState";
138:
139: /**
140: * 10.2.1.6 wsrp-fragmentID <p>This portlet URL parameter specifies the portion of an URL that navigates to a place
141: * within a document.</p>
142: */
143: public static final String FRAGMENT_ID = "wsrp-fragmentID";
144:
145: /**
146: * 10.2.1.7 wsrp-secureURL <p>The value for the wsrp-secureURL is a boolean indicating whether the resulting URL MUST
147: * involve secure communication between the client and Consumer, as well as between the Consumer and Producer. The
148: * default value of this boolean is "false". Note that the Consumer"s aggregated page MUST be secure if any of the
149: * Portlets whose content is being displayed on the page have indicated the need for secure communication for their
150: * current markup.</p>
151: */
152: public static final String SECURE_URL = "wsrp-secureURL";
153:
154: /**
155: * 10.3.1 Consumer Rewriting (Namespace encoding) <p>The Portlet can prefix the token with "wsrp_rewrite_". The
156: * Consumer will locate such markers and MUST replace them with a prefix that is unique to this instance of this
157: * portlet on the page. This prefix has been chosen such that the Consumer is able to do a single parse of the markup
158: * to both locate such markers and the URL rewrite expressions described in section 10.2.1. In addition, this prefix
159: * is legal for at least the JavaScript and VBScript scripting languages and CSS class names. This permits the
160: * independent testing of most generated markup fragments.</p>
161: */
162: public static final String WSRP_REWRITE_TOKEN = WSRP_REWRITE + "_";
163:
164: /** Opening token for URL parameters. See 10.2.2. */
165: public static final String REWRITE_PARAMETER_OPEN = "{";
166:
167: /** Closing token for URL parameters. See 10.2.2. */
168: public static final String REWRITE_PARAMETER_CLOSE = "}";
169:
170: /** Encoded version of REWRITE_PARAMETER_OPEN */
171: static final String ENC_OPEN = "%7B";
172:
173: /** Encoded version of REWRITE_PARAMETER_CLOSE */
174: static final String ENC_CLOSE = "%7D";
175:
176: /* Constants for Resource URL processing */
177: public static final String FAKE_RESOURCE_START = "JBP_RES_REW=";
178: public static final String FAKE_RESOURCE_REQ_REW = "JBP_REQ_REW";
179: public static final String FAKE_RESOURCE_URL = FAKE_RESOURCE_START
180: + "{wsrp-url}" + FAKE_RESOURCE_REQ_REW
181: + "{wsrp-requiresRewrite}";
182:
183: private WSRPRewritingConstants() {
184: }
185: }
|