⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basejetspeedlink.java

📁 jetspeed源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/*
 * Copyright 2000-2001,2004 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.jetspeed.util.template;

// Jetspeed
import org.apache.jetspeed.om.profile.Entry;
import org.apache.jetspeed.om.profile.Profile;
import org.apache.jetspeed.om.profile.Portlets;
import org.apache.jetspeed.om.profile.ProfileException;
import org.apache.jetspeed.om.profile.ProfileLocator;
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
import org.apache.jetspeed.services.logging.JetspeedLogger;
import org.apache.jetspeed.services.resources.JetspeedResources;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.util.template.JetspeedLink;

// Turbine
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.DynamicURI;
import org.apache.turbine.services.pull.ApplicationTool;

/**
 * <p>A customized version of the TemplateLink which can handle portlet
 * references.</p>
 *
 * <p>It is inserted into the template context by Turbine, via request tools.</p>
 *
 * <p>Each portlet must call setPortlet(this) on it before entering the template
 * rendering code. This is done currently in VelocityPortlet.</p>
 *
 * @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
 * @version $Id: BaseJetspeedLink.java,v 1.23 2004/02/23 03:20:45 jford Exp $
 */
public class BaseJetspeedLink implements ApplicationTool, JetspeedLink
{
    /**
     * Static initialization of the logger for this class
     */    
    private static final JetspeedLogger logger = JetspeedLogFactoryService.getLogger(BaseJetspeedLink.class.getName());
    
    /**
     *<p>Request to which we refer.</p>
     */
    private JetspeedRunData rundata = null;

    /**
     * Profile locator from <code>rundata</code>.  This is here
     * for performance reasons.
     */
    private ProfileLocator locator = null;

    /**
     * Profile from <code>rundata</code>.  This is here
     * for performance reasons.
     */
    private Profile profile = null;

    /**
     * Has the initialization for the current rundata been performed?.  This is
     * here for performance reasons.
     */
    private boolean initDone = false;

    /**
     *<p>The portlet that will be used to build the reference.</p>
     */
    protected Portlet activePortlet = null;

    /**
     * Empty constructor.for introspection
     */
    public BaseJetspeedLink()
    {
    }

    /**
     * Constructor required by ApplicationTool interface
     *
     * @param data A Jetspeed RunData object.
     */
    public BaseJetspeedLink(RunData data)
    {
        init((Object) data);
    }

    /**
     * This will initialise a JetspeedLink object that was
     * constructed with the default constructor
     *
     * @param rundata to be a RunData object
     */
    public void init(RunData rundata)
    {
        init((Object) rundata);
    }

    /**
     * Adds a name=value pair to the query string.
     *
     * @param name A String with the name to add.
     * @param value An Object with the value to add.
     * @return DynamicURI that to the desired page
     */
    public DynamicURI addQueryData(String name, Object value)
    {
        try
        {
            return getRoot().addQueryData(name, value);
        }
        catch (ProfileException e)
        {
            logger.error("Exception",  e);
            return null;
        }
    }

    /**
     * Adds a name=value pair to the path_info string.
     *
     * @param name A String with the name to add.
     * @param value An Object with the value to add.
     * @return DynamicURI that to the desired page
     */
    public DynamicURI addPathInfo(String name, Object value)
    {
        try
        {
            return getRoot().addPathInfo(name, value);
        }
        catch (ProfileException e)
        {
            logger.error("Exception",  e);
            return null;
        }
    }

    /**
     * Return an link to a specific portal element
     *
     * @param peid of the portal element
     * @return DynamicURI to specific portal element
     *
     * @deprecated Use getPortletById() or getPaneById()
     */
    public DynamicURI setPortalElement(String peid)
    {
        if (initDone == false)
        {
            initLink();
        }
        if (profile.getDocument().getEntryById(peid) != null)
        {
            return getPortletById(peid);
        }
        else
        {
            return setPaneById(peid);
        }
    }

    /**
     * Return an link to a specific portlet using the portet's id
     *
     * @param peid of the portlet
     * @return DynamicURI to specific portlet
     *
     * @deprecated Use getPortletById()
     */
    public DynamicURI setPortletById(String peid)
    {
        return getPortletById(peid);
    }

    /**
     * Return link to the home page without user,
     * page, group, role, template, action, media type, language, or country
     * in link.
     *
     * @return DynamicURI to the home page
     */
    public DynamicURI getHomePage()
    {
        return getLink(JetspeedLink.DEFAULT, null, "", JetspeedLink.DEFAULT, null, "", "", "", "", "");
    }

    /**
     * Return a link that includes the template
     * from rundata
     *
     * @return DynamicURI to template
     */
    public DynamicURI getTemplate()
    {
        String template = rundata.getRequestedTemplate();
        return getLink(JetspeedLink.CURRENT, null, null, JetspeedLink.DEFAULT, null, null, template, null, null, null);
    }

    /**
     * Return a link to the template.
     *
     * @param template to add to link
     * @return DynamicURI to specific portlet
     *
     * @deprecated Use getTemplate()
     */
    public DynamicURI setTemplate(String template)
    {
        return getTemplate(template);
    }

    /**
     * Return a link that includes an action
     *
     * @param action Desired action
     * @return DynamicURI that includes the desire action
     *
     * @deprecated Use getAction()
     */
    public DynamicURI setAction(String action)
    {
        return getAction(action);
    }

    /**
     * Return a link that includes an action to a specific portlet, as defined
     * by a portlets
     *
     * @param action Desired action
     * @param portlets to receive the action
     * @return DynamicURI that includes the desire action
     *
     * @deprecated Use getAction()
     */
    public DynamicURI setAction(String action, Portlets portlets)
    {
        return getAction(action, (Portlets) portlets);
    }

    /**
     * Return a link that includes an action to a specific portlet
     *
     * @param action Desired action
     * @param portlet to receive the action
     * @return DynamicURI that includes the desire action
     *
     * @deprecated Use getAction()
     */
    public DynamicURI setAction(String action, Portlet portlet)
    {
        return getAction(action, (Portlet) portlet);
    }

    /**
     * Return a link that includes an action to a specific portlet, as defined
     * by an entry
     *
     * @param action Desired action
     * @param entry to receive the action
     * @return DynamicURI that includes the desire action
     *
     * @deprecated Use getAction()
     */
    public DynamicURI setAction(String action, Entry entry)
    {
        return getAction(action, (Entry) entry);
    }

    /**
     * Return a link that includes an action to a specific portlet, as defined
     * by a PEID
     *
     * @param action Desired action
     * @param peid Id of portlet to receive the action
     * @return DynamicURI that includes the desire action
     * @deprecated Use getAction()
     */
    public DynamicURI setAction(String action, String peid)
    {
        return getAction(action, (String) peid);
    }

    /**
     * Return a link to a default page for the group
     *
     * @param group Desired group
     * @return DynamicURI that to the desired page
     *
     * @deprecated Use getGroup()
     */
    public DynamicURI setGroup(String group)
    {
        return getGroup(group);
    }

    /**
     * Return a link to a desired page for the group
     *
     * @param page Desired page
     * @param group Desired group
     * @return DynamicURI that to the desired page
     *
     * @deprecated Use getGroup()
     */
    public DynamicURI setGroup(String group, String page)
    {
        return getGroup(group, page);
    }

    /**
     * Return a link to a default page for the
     * current user, group, or role.
     *
     * @return DynamicURI that to the desired page
     *
     * @deprecated Use getPage()
     */
    public DynamicURI setPage()
    {
        return getPage();
    }

    /**
     * Return a link to a desired page for the
     * current user, group, or role.
     *
     * @param page Desired page
     * @return DynamicURI that to the desired page
     *
     * @deprecated Use getPage()
     */
    public DynamicURI setPage(String page)
    {
        return getPage(page);
    }

    /**
     * Return a link to a desired page and pane for the
     * current user, group, or role.
     *
     * @param page Desired page
     * @param paneName Desired pane name
     * @return DynamicURI that to the desired page
     * @deprecated Use getPage()
     */
    public DynamicURI setPage(String page, String paneName)
    {
        return getPage(page, paneName);
    }


    /**
     * Return a link to a default page for the role
     *
     * @param role Desired role
     * @return DynamicURI that to the desired page
     *
     * @deprecated use getRole()
     */
    public DynamicURI setRole(String role)
    {
        return getRole(role);
    }

    /**
     * Return a link to a desired page for the role
     *
     * @param role Desired role
     * @param page Desired page
     * @return DynamicURI that to the desired page
     *
     * @deprecated use getRole()
     */
    public DynamicURI setRole(String role, String page)
    {
        return getRole(role, page);
    }

    /**
     * Return a link to a default page for the user
     *
     * @param user Desired user
     * @return DynamicURI that to the desired page
     *
     * @deprecated Use getUser()
     */
    public DynamicURI setUser(String user)
    {
        return getUser(user);
    }

    /**
     * Return a link to a desired page for the user
     *
     * @param page Desired page
     * @param user Desired user
     * @return DynamicURI that to the desired page
     *
     * @deprecated  Use getUser()
     */
    public DynamicURI setUser(String user, String page)
    {
        return getUser(user, page);
    }

    /**
     * Return a link to a specific pane using the pane's id
     *
     * @param paneId of the Pane
     * @return URI to specific portlet
     *
     * @deprecated Use getPaneById()
     */
    public DynamicURI setPaneById(String paneId)
    {
        return getPaneById(paneId);
    }

    /**
     * Return a link to a specific pane using the pane's id
     *
     * @param paneName Name of the Pane
     * @return URI to specific portlet
     * @deprecated Use getPaneByName()
     */
    public DynamicURI setPaneByName(String paneName)
    {
        return getPaneByName(paneName);
    }

    /**
     * Return a link to a desired page.  This is allows the inclusion of a Group/Role/User,
     * page, template, action, media type, language, and country.
     * 
     * @param rootType   Type of root PSML docuument.  The should be one of the following:
     *                   <dl>
     *                   <dt>JetspeedLink.CURRENT</dt><dd>The link will retain the current Group/Role/User referance. rootValue is not used</dd>
     *                   <dt>JetspeedLink.DEFAULT</dt><dd>Default Group, Role, or User. rootValue is not used</dd>
     *                   <dt>JetspeedLink.GROUP</dt><dd>Link will be to a Group PSML.  rootValue is a Group Name</dd>
     *                   <dt>JetspeedLink.ROLE</dt><dd>Link will be to a Role PSML.  rootValue is a Role Name</dd>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -