1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */1617packageorg.apache.jetspeed.portal;
181920//jetspeed support21import org.apache.jetspeed.om.registry.RegistryEntry;
22import org.apache.jetspeed.om.registry.PortletEntry;
23import org.apache.jetspeed.services.Registry;
2425//turbine26import org.apache.turbine.util.DynamicURI;
27import org.apache.turbine.util.ParameterParser;
28import org.apache.turbine.util.RunData;
2930/***31<p>32Handles providing URIs to Portlet interface providers.33</p>3435<p>36The URIs are based on the individual actions such as Edit/Max. Editing a37portlet allows you to preview it and perform certain actions such as subscribing38to it or adding it to your Mozilla sidebar. Maximizing a portlet allows you to39view this portlet at full screen.40</p>4142<p>43The following HTTP parameters are used to allow Jetspeed to figure out what to44render:4546 <pre>47 name: fetches the name from the portlet registry and then adds some more info:48 - url: the URL on which this portlet is based49 - parameter-{NAME]: allows the client to add params to a Portlet50 - metainfo-[NAME}: allows the client to supply the title or description51 of the Portlet52 </pre>5354</p>5556@author <a href="mailto:burton@apache.org">Kevin A. Burton</a>57@author <a href="mailto:sgala@hisitech.com">Santiago Gala</a>58@version $Id: PortletURIManager.java,v 1.40 2004/02/23 04:05:35 jford Exp $59*/6061publicclassPortletURIManager {
6263//Utility methods6465/***66 Get a PortletURI by it's name and rundata6768 @see #getPortletMaxURI( RegistryEntry, RunData)69 */70publicstatic DynamicURI getPortletMaxURI( String name, RunData data ) {
71return getPortletMaxURI(
72 Registry.getEntry(Registry.PORTLET, name ),
73 data );
74 }
7576/***77 Get a URI for viewing this portlet by itself. This is the only method that78 will work if the user has disabled cookies.79 */8081publicstatic DynamicURI getPortletEditURI( Portlet portlet,
82 RunData data) {
8384 DynamicURI uri = new DynamicURI( data, "Info" );
85 uri.addPathInfo( "portlet", portlet.getName() );
8687return uri;
8889 }
909192/***93 Get a URL for viewing this URL full screen. This is the only method that94 will work if the user has disabled cookies.95 */96publicstatic DynamicURI getPortletMaxURI( RegistryEntry entry, RunData data ) {
9798 DynamicURI uri = new DynamicURI( data );
99100 uri.addPathInfo( "portlet", entry.getName() );
101102return uri;
103104 }
105106/***107 <p>108 Given a ParameterParser, get a PortletEntry. This is used so that when you have a109 URI created from PortletURIManager you can get back the PortletEntry that created110 it originally.111 </p>112113 <p>114 Return null if we aren't able to figure out the PortletEntry115 </p>116 */117publicstaticfinalPortletEntry getEntry( ParameterParser params )
118 {
119 String name = params.getString( "portlet" );
120return (PortletEntry)Registry.getEntry(Registry.PORTLET, name );
121 }
122123 }