Package org.apache.jetspeed.portal

Examples of org.apache.jetspeed.portal.Portlet


    /**
    Returns the Portlet with the given id
    */
    public Portlet getPortletByID(String id)
    {
        Portlet p = getPortlet();
         if (null == p)
            return null;

        if (p instanceof PortletSet)
        {
            Enumeration e = ((PortletSet)p).getPortlets();
            Portlet portlet = null;
            while ( e.hasMoreElements() )
            {
                portlet = (Portlet)e.nextElement();
                if (portlet.getID().equals(id))
                    return portlet;
            }
            return portlet;
       }
       return null;
View Full Code Here


    /**
    Returns the Portlet with the given name
    */
    public Portlet getPortletByName(String name)
    {
        Portlet p = getPortlet();
         if (null == p)
            return null;

        if (p instanceof PortletSet)
        {
            Enumeration e = ((PortletSet)p).getPortlets();
            Portlet portlet = null;
            while ( e.hasMoreElements() )
            {
                portlet = (Portlet)e.nextElement();
                if (portlet.getName().equals(name))
                    return portlet;
            }
            return portlet;
       }
       return null;
View Full Code Here

     * @deprecated Use getPortletById()
     */
    public ConcreteElement getPortlet(String name)
    {
        ConcreteElement result = null;
        Portlet found = null;
        Stack sets = new Stack();
        sets.push(rundata.getProfile().getRootSet());
       
        while ((sets.size() > 0) && (found==null))
        {
            PortletSet set = (PortletSet)sets.pop();
           
            if (set.getName().equals(name))
            {
                found = set;
            }
            else
            {
                Enumeration en = set.getPortlets();
                while((found==null) && en.hasMoreElements())
                {
                    Portlet p = (Portlet)en.nextElement();
                       
                    // unstack the controls to find the real PortletSets
                    Portlet real = p;
                    while (real instanceof PortletControl)
                    {
                        real = ((PortletControl)p).getPortlet();
                    }
                       
View Full Code Here

     @param data the RunData for this request
     *  @return the portlet object of the appropriate customizer
     */
    public static Portlet getCustomizer(Portlet p)
    {
        Portlet customizer = p;

        while (p instanceof PortletControl)
        {
            p = ((PortletControl)p).getPortlet();
        }
       
        // if the portlet cannot customize itself...
        if ( !p.providesCustomization() )
        {

            //look for the customizer name in the portlet
            //config (from Registry definition)
       
            String name = p.getPortletConfig().getInitParameter("_customizer");
           
            if (name == null)
            {
                String key = (p instanceof PortletSet)?"PortletSet":"Portlet";           

                name = JetspeedResources.getString("customizer."+key,key+"Customizer");
            }
       
            try
            {
                customizer = PortletFactory.getPortlet(name, p.getID()+"customize");
                customizer.getPortletConfig()
                          .setPortletSkin(p.getPortletConfig().getPortletSkin());
                PortletControl control = PortalToolkit.getControl((String)null);
                if (control!=null)
                {
                    control.setPortlet(customizer);
View Full Code Here

      @param data the RunData for this request
      *  @return the portlet object of the appropriate customizer
      */
     public static Portlet getPortletInfoPortlet(RunData data)
     {
         Portlet info = null;
        
         String name = JetspeedResources.getString("PortletInfoPortlet.name", "PortletInfoPortlet");
         try {
             if (null != data)
             {
                 JetspeedRunData jdata = (JetspeedRunData)data;
                 Profile profile = jdata.getProfile();
                 if (null == profile)
                 {
                     logger.warn("JetspeedTool: profile is null");
                     profile = Profiler.getProfile(jdata);
                     jdata.setProfile(profile);
                 }
                 Portlet source = findPortlet(data);
                 if (source != null) {
                     jdata.setPortlet(source.getName());
                     info = PortletFactory.getPortlet(name, "PortletInfoPortlet");
                     info.getPortletConfig().setPortletSkin(source.getPortletConfig().getPortletSkin());
                     PortletControl control = PortalToolkit.getControl((String)null);
                     if (control != null)
                     {
                         control.setPortlet(info);
                         control.init();
View Full Code Here

      * @param rundata for this request
      * @return portlet identified by js_peid
      */
     private static Portlet findPortlet(RunData rundata) {
         Portlet found = null;
         JetspeedRunData jdata = (JetspeedRunData)rundata;
         String peid = jdata.getJs_peid();
         if (peid != null)
         {
             Stack sets = new Stack();
             sets.push(jdata.getProfile().getRootSet());
             while ((found==null) && (sets.size() > 0))
             {
                 PortletSet set = (PortletSet)sets.pop();
                 if (set.getID().equals(peid))
                 {
                     found = set;
                 }
                 else
                 {
                     Enumeration en = set.getPortlets();
                     while((found==null) && en.hasMoreElements())
                     {
                         Portlet p = (Portlet)en.nextElement();
                         // unstack the controls to find the real PortletSets
                         Portlet real = p;
                         while (real instanceof PortletControl)
                         {
                             real = ((PortletControl)p).getPortlet();
                         }
                         if (real instanceof PortletSet)
                         {
                             if (real.getID().equals(peid))
                             {
                                 found=real;
                             }
                             else
                             {
View Full Code Here

                        // Portlets ps = doc.getPortletsById(id);
                        result = new  StringElement("not implemented - PortletElement");
                    }
                    else
                    {
                        Portlet p = PortletFactory.getPortlet( entry );
                        if (p != null)
                        {
                            result = p.getContent(rundata);
                        }
                        else
                           result = new  StringElement("Error retrieving PortletElement");

                    }
View Full Code Here

     * @return the rendered content of the portlet
     */
    public ConcreteElement getPortletById(String peid)
    {
        ConcreteElement result = null;
        Portlet found = null;
        Stack sets = new Stack();
        sets.push(rundata.getProfile().getRootSet());
       
        while ((sets.size() > 0) && (found==null))
        {
            PortletSet set = (PortletSet)sets.pop();
           
            if (set.getID().equals(peid))
            {
                found = set;
            }
            else
            {
                Enumeration en = set.getPortlets();
                while((found==null) && en.hasMoreElements())
                {
                    Portlet p = (Portlet)en.nextElement();
                       
                    // unstack the controls to find the real PortletSets
                    Portlet real = p;
                    while (real instanceof PortletControl)
                    {
                        real = ((PortletControl)p).getPortlet();
                    }
                       
View Full Code Here

     */
    public ConcreteElement getPortletFromRegistry(RunData data)
    {

        ConcreteElement result = null;
        Portlet p = null;
        String portletName = data.getParameters().getString("p");
        String controlName = data.getParameters().getString("c");
       
        try
        {

            // Retrieve registry entry
            PortletEntry entry = (PortletEntry) Registry.getEntry(Registry.PORTLET, portletName);

            // Verify security for the parameter
            boolean canAccess = JetspeedSecurity.checkPermission((JetspeedUser) data.getUser(),
                                                                 new PortalResource(entry),
                                                                 JetspeedSecurity.PERMISSION_CUSTOMIZE);

            if (canAccess)
            {
                // Always set portlet id to "preview" so each preview request gets it from the cache.
                // At least, I think that's how it works.
                p = PortletFactory.getPortlet(portletName, "preview");
                PortletControl control = controlName == null ? PortalToolkit.getControl((String) null)
                                                             : PortalToolkit.getControl(controlName);
                if (control != null)
                {
                    JetspeedRunData jdata = (JetspeedRunData) rundata;
                    // Use the profile's skin
                    p.getPortletConfig().setPortletSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
                    control.setPortlet(p);
                    control.init();
                    result = control.getContent(rundata);
                }
                else if (p != null)
                {
                    result = p.getContent(rundata);
                }
            }
            else
            {
                result = new JetspeedClearElement(Localization.getString(data, "SECURITY_NO_ACCESS_TO_PORTLET"));
View Full Code Here

     */
    public ConcreteElement getPortletFromRegistry(String portletName, String controlName)
    {

        ConcreteElement result = null;
        Portlet p = null;
       
        try
        {
            // Always set portlet id to "preview" so each preview request gets it from the cache.
            // At least, I think that's how it works.
            p = PortletFactory.getPortlet(portletName, "preview");
            PortletControl control = controlName == null ? PortalToolkit.getControl((String) null)
                                                         : PortalToolkit.getControl(controlName);
            if (control != null)
            {
                JetspeedRunData jdata = (JetspeedRunData) rundata;
                // Use the profile's skin
                p.getPortletConfig().setPortletSkin(PortalToolkit.getSkin(jdata.getProfile().getDocument().getPortlets().getSkin()));
                control.setPortlet(p);
                control.init();
                result = control.getContent(rundata);
            }
            else if (p != null)
            {
                result = p.getContent(rundata);
            }
        }
        catch (Exception e)
        {
            logger.error("Exception",  e);
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.portal.Portlet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.