1/*2 * Copyright 2000-2001,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.util.template;
1819// Jetspeed20import org.apache.jetspeed.portal.Portlet;
21import org.apache.jetspeed.om.profile.Entry;
22import org.apache.jetspeed.om.profile.Portlets;
2324// Turbine25import org.apache.turbine.util.DynamicURI;
26import org.apache.turbine.util.RunData;
2728/***29 * <p>A customized version of the TemplateLink which can handle portlet30 * references.</p>31 *32 * <p>It is inserted into the template context by Turbine, via request tools.</p>33 *34 * <p>Each portlet must call setPortlet(this) on it before entering the template35 * rendering code. This is done currently in VelocityPortlet.</p>36 *37 * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>38 * @version $Id: JetspeedLink.java,v 1.15 2004/03/11 03:08:53 paulsp Exp $39 */40publicinterfaceJetspeedLink {
4142publicstaticint CURRENT = 101;
43publicstaticint DEFAULT = 102;
44publicstaticint GROUP = 201;
45publicstaticint ROLE = 202;
46publicstaticint USER = 203;
47publicstaticint PANE_ID = 301;
48publicstaticint PANE_NAME = 302;
49publicstaticint PORTLET_ID = 303;
50publicstaticint PORTLET_NAME = 304;
51publicstaticint PORTLET_ID_QUERY = 305;
525354/***55 * Adds a name=value pair to the path_info string.56 *57 * @param name A String with the name to add.58 * @param value An Object with the value to add.59 * @return DynamicURI that to the desired page60 */61public DynamicURI addPathInfo(String name, Object value);
6263/***64 * Adds a name=value pair to the query string.65 *66 * @param name A String with the name to add.67 * @param value An Object with the value to add.68 * @return DynamicURI that to the desired page69 */70public DynamicURI addQueryData(String name, Object value);
7172/***73 * Return the action key. Used by velocity templates, i.e. $jlink.ActionKey74 *75 * @return the action parameter name76 */77public String getActionKey();
7879/***80 * Return link to the home page without user,81 * page, group, role, template, action, media type, language, or country82 * in link.83 * @return DynamicURI to the home page84 */85public DynamicURI getHomePage();
8687/***88 * This will initialise a JetspeedLink object that was89 * constructed with the default constructor90 *91 * @param rundata to be a RunData object92 */93publicvoid init(RunData rundata);
9495/***96 * Return a link that includes the template97 * from rundata98 *99 * @return DynamicURI to template100 */101public DynamicURI getTemplate();
102103/***104 * Is the PSML for the anonymous user?105 *106 * @return True = PSML is for the anonymous user107 */108publicboolean getAnonymous();
109110/***111 * Return country of the PSML file112 *113 * @return Country of PSML, or null if no country114 */115public String getCountry();
116117/***118 * Return Group name of the PSML file119 *120 * @return Group name of PSML, or null if no Group name121 */122public String getGroupName();
123124/***125 * Return Language of the PSML file126 *127 * @return Language of PSML, or null if no Language128 */129public String getLanguage();
130131/***132 * Return Media Type of the PSML file133 *134 * @return Media Type of PSML, or null if no Media Type135 */136public String getMediaType();
137138/***139 * Return Page name of the PSML file140 *141 * @return Page name of PSML, or null if no Page name142 */143public String getPageName();
144145/***146 * Return Role name of the PSML file147 *148 * @return Role name of PSML, or null if no Role name149 */150public String getRoleName();
151152/***153 * Return User name of the PSML file154 *155 * @return User name of PSML, or null if no User name156 */157public String getUserName();
158159/***160 * Return a link that includes an action161 *162 * @param action action163 * @return DynamicURI that includes the desire action164 */165public DynamicURI getAction(String action);
166167/***168 * Return a link that includes an action to a specific portlet, as defined169 * by an entry170 *171 * @param action Desired action172 * @param entry to receive the action173 * @return DynamicURI that includes the desire action174 */175public DynamicURI getAction(String action, Entry entry);
176177/***178 * Return a link that includes an action to a specific portlet, as defined179 * by a portlet180 *181 * @param action Desired action182 * @param portlet to receive the action183 * @return DynamicURI that includes the desire action184 */185public DynamicURI getAction(String action, Portlet portlet);
186187/***188 * Return a link that includes an action to a specific portlet, as defined189 * by a portlets190 *191 * @param action Desired action192 * @param portlet to receive the action193 * @return DynamicURI that includes the desire action194 */195public DynamicURI getAction(String action, Portlets portlet);
196197/***198 * Return a link that includes an action to a specific portlet, as defined199 * by a PEID200 *201 * @param action Desired action202 * @param peid Id of portlet to receive the action203 * @return DynamicURI that includes the desire action204 */205public DynamicURI getAction(String action, String peid);
206207/***208 * Return a link to a default page for the group209 *210 * @param group Desired group211 * @return DynamicURI that to the desired page212 */213public DynamicURI getGroup(String group);
214215/***216 * Return a link to a desired page for the group217 *218 * @param page Desired page219 * @param group Desired group220 * @return DynamicURI that to the desired page221 */222public DynamicURI getGroup(String group, String page);
223224/***225 * Return a link to a default page for the226 * current user, group, or role.227 *228 * @return DynamicURI that to the desired page229 */230public DynamicURI getPage();
231232/***233 * Return a link to a desired page for the234 * current user, group, or role.235 *236 * @param page Desired page237 * @return DynamicURI that to the desired page238 */239public DynamicURI getPage(String page);
240241/***242 * Return a link to a desired page and pane for the243 * current user, group, or role.244 *245 * @param page Desired page246 * @param paneName Name of desired pane247 * @return DynamicURI that to the desired page248 */249public DynamicURI getPage(String page, String paneName);
250251/***252 * Return an link to a specific portlet using the portet's id253 *254 * @param peid of the portlet255 * @return DynamicURI to specific portlet256 *257 */258public DynamicURI getPortletById(String peid);
259260/***261 * Add a portlet reference in the link.262 *263 * Note: This must be used with caution, since a portlet may exist may times264 * in a PSML. setPortletById() is the perfered method.265 *266 * @param portletName the name of the portlet to link to267 * @return a DynamicURI referencing the named portlet for easy link construction in template268 *269 * @deprecated Use getPortletById() 270 */271public DynamicURI getPortletByName(String portletName);
272273/***274 * Return a link to a default page for the role275 *276 * @param role Desired role277 * @return DynamicURI that to the desired page278 */279public DynamicURI getRole(String role);
280281/***282 * Return a link to a desired page for the role283 *284 * @param role Desired role285 * @param page Desired page286 * @return DynamicURI that to the desired page287 */288public DynamicURI getRole(String role, String page);
289290/***291 * Return a link to the template.292 *293 * @param template to add to link294 * @return DynamicURI to specific portlet295 */296public DynamicURI getTemplate(String template);
297298/***299 * Return a link to a default page for the user300 *301 * @param user Desired user302 * @return DynamicURI that to the desired page303 */304public DynamicURI getUser(String user);
305306/***307 * Return a link to a desired page for the user308 *309 * @param page Desired page310 * @param user Desired user311 * @return DynamicURI that to the desired page312 */313public DynamicURI getUser(String user, String page);
314315/***316 * Return a link that includes an action317 *318 * @param action action319 * @return DynamicURI that includes the desire action320 * @deprecated Use getAction()321 */322public DynamicURI setAction(String action);
323324/***325 * Return a link that includes an action to a specific portlet, as defined326 * by an entry327 *328 * @param action Desired action329 * @param entry to receive the action330 * @return DynamicURI that includes the desire action331 *332 * @deprecated use getAction()333 */334public DynamicURI setAction(String action, Entry entry);
335336/***337 * Return a link that includes an action to a specific portlet, as defined338 * by a portlet339 *340 * @param action Desired action341 * @param portlet to receive the action342 * @return DynamicURI that includes the desire action343 *344 * @deprecated use getAction()345 */346public DynamicURI setAction(String action, Portlet portlet);
347348/***349 * Return a link that includes an action to a specific portlet, as defined350 * by a portlets351 *352 * @param action Desired action353 * @param portlet to receive the action354 * @return DynamicURI that includes the desire action355 *356 * @deprecated use getAction()357 */358public DynamicURI setAction(String action, Portlets portlet);
359360/***361 * Return a link to a default page for the group362 *363 * @param group Desired group364 * @return DynamicURI that to the desired page365 *366 * @deprecated use getGroup()367 */368public DynamicURI setGroup(String group);
369370/***371 * Return a link to a desired page for the group372 *373 * @param page Desired page374 * @param group Desired group375 * @return DynamicURI that to the desired page376 *377 * @deprecated use getGroup()378 */379public DynamicURI setGroup(String group, String page);
380381/***382 * Return a link to a default page for the383 * current user, group, or role.384 *385 * @return DynamicURI that to the desired page386 *387 * @deprecated use getPage()388 */389public DynamicURI setPage();
390391/***392 * Return a link to a desired page for the393 * current user, group, or role.394 *395 * @param page Desired page396 * @return DynamicURI that to the desired page397 *398 * @deprecated use getPage()399 */400public DynamicURI setPage(String page);
401402/***403 * Return a link to a desired page and pane for the404 * current user, group, or role.405 *406 * @param page Desired page407 * @param paneName Name of desired pane408 * @return DynamicURI that to the desired page409 *410 * @deprecated use getPage()411 */412public DynamicURI setPage(String page, String paneName);
413414public DynamicURI setMediaType(String mediaType);
415416/***417 * Return an link to a specific portlet using the portet's id418 *419 * @param peid of the portlet420 * @return DynamicURI to specific portlet421 *422 * @deprecated use getPortletById()423 */424public DynamicURI setPortletById(String peid);
425426/***427 * Return an link to a specific portal element428 *429 * @param peid of the portal element430 * @return DynamicURI to specific portal element431 *432 * @deprecated use getPortletById or getPaneById()433 */434public DynamicURI setPortalElement(String peid);
435436/***437 * Add a portlet reference in the link.438 *439 * Note: This must be used with caution, since a portlet may exist may times440 * in a PSML. setPortletById() is the perfered method.441 *442 * @param portletName the name of the portlet to link to443 * @return a DynamicURI referencing the named portlet for easy link construction in template444 *445 * @deprecated use getPortletByName()446 */447public DynamicURI setPortletByName(String portletName);
448449/***450 * Return a link to a default page for the role451 *452 * @param role Desired role453 * @return DynamicURI that to the desired page454 *455 * @deprecated use getRole()456 */457public DynamicURI setRole(String role);
458459/***460 * Return a link to a desired page for the role461 *462 * @param role Desired role463 * @param page Desired page464 * @return DynamicURI that to the desired page465 *466 * @deprecated use getRole()467 */468public DynamicURI setRole(String role, String page);
469470/***471 * Return a link to the template.472 *473 * @param template to add to link474 * @return DynamicURI to specific portlet475 *476 * @deprecated use getTemplate()477 */478public DynamicURI setTemplate(String template);
479480/***481 * Return a link to a default page for the user482 *483 * @param user Desired user484 * @return DynamicURI that to the desired page485 *486 * @deprecated use getUser()487 */488public DynamicURI setUser(String user);
489490/***491 * Return a link to a desired page for the user492 *493 * @param page Desired page494 * @param user Desired user495 * @return DynamicURI that to the desired page496 *497 * @deprecated use getUser()498 */499public DynamicURI setUser(String user, String page);
500501/***502 * Return a URL, as a string, the the root page or pane.503 *504 * @return a URL, as a string, the the root page or pane.505 */506public String toString();
507508/***509 * Return a link to a specific pane using the pane's id510 *511 * @param paneId of the Pane512 * @return URI to specific portlet513 * @deprecated Use getPaneById()514 */515public DynamicURI setPaneById(String paneId);
516517/***518 * Return a link to a specific pane using the pane's id519 *520 * @param paneId of the Pane521 * @return URI to specific portlet522 */523public DynamicURI getPaneById(String paneId);
524525/***526 * Return a link to a specific pane using the pane's id527 *528 * @param paneName Name of the Pane529 * @return URI to specific portlet530 */531public DynamicURI getPaneByName(String paneName);
532533/***534 * depreceted methods from JetspeedTemplateLink.535 */536537/***538 * <p> Set the portlet giving context to this Link object.</p>539 *540 * This method is from JetspeedTemplateLink and is only here541 * for backward compatibility. This it should not be used for542 * any new development. Also any problems with this method will543 * not be fixed544 *545 * @param portlet the name of the active portlet546 * @deprecated Use getLink() or getAction() or getPortletById() or getPortletByName().547 */548publicvoid setPortlet(Portlet portlet);
549550/***551 * Return a link to a desired page. This is allows the inclusion of a Group/Role/User,552 * page, template, action, media type, language, and country.553 *554 * @param rootType Type of root PSML docuument. The should be one of the following:555 * <dl>556 * <dt>JetspeedLink.CURRENT</dt><dd>The link will retain the current Group/Role/User referance. rootValue is not used</dd>557 * <dt>JetspeedLink.DEFAULT</dt><dd>Default Group, Role, or User. rootValue is not used</dd>558 * <dt>JetspeedLink.GROUP</dt><dd>Link will be to a Group PSML. rootValue is a Group Name</dd>559 * <dt>JetspeedLink.ROLE</dt><dd>Link will be to a Role PSML. rootValue is a Role Name</dd>560 * <dt>JetspeedLink.USER</dt><dd>Link will be to a User PSML. rootValue is a User Name</dd>561 * </dl>562 * @param rootValue See description of rootType563 * @param pageName Name of page. null = default page564 * @param elementType565 * <dl>566 * <dt>JetspeedLink.CURRENT</dt><dd>The link will retain the current Pane/Portlet referance. elementValue is not used</dd>567 * <dt>JetspeedLink.DEFAULT</dt><dd>The link will NOT referance a pane or portlet. elementValue is not used</dd>568 * <dt>JetspeedLink.PANE_ID</dt><dd>Link will be to a Pane using it's ID. elementValue is a Pane's ID</dd>569 * <dt>JetspeedLink.PANE_NAME</dt><dd>Link will be to a Pane using it's Name. elementValue is a Pane's Name</dd>570 * <dt>JetspeedLink.PORTLET_ID</dt><dd>Link will be to a Portlet using it's ID. elementValue is a Portlet's ID</dd>571 * <dt>JetspeedLink.PORTLET_NAME</dt><dd>Link will be to a Portlet using it's Name. elementValue is a Portlet's Name</dd>572 * </dl>573 * @param elementValue See description of elementType574 * @param actionName Name of action. If no action is desired use JetspeedLink.NO_ACTION.575 * @param templateName Name of template. If no template is desired use JetspeedLink.NO_TEMPLATE.576 * @param mediaType Desired media type. null = default media type577 * @param language Desired language. null = default language578 * @param country Desired country. null = default language579 * @return URI to specific portlet580 */581public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName, String mediaType, String language, String country);
582/***583 * @see # org.apache.jetspeed.util.template.JetspeedLink.getLink( int, String, String, int, String, String, String, String, String, String584 */585public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName, String mediaType, String language);
586public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName, String mediaType);
587public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName, String templateName);
588public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue, String actionName);
589public DynamicURI getLink(int rootType, String rootValue, String pageName, int elementType, String elementValue);
590591 }